diff --git a/packages/compiler-sfc/src/compileScript.ts b/packages/compiler-sfc/src/compileScript.ts index 2c0f9f2468d..275945a2bfa 100644 --- a/packages/compiler-sfc/src/compileScript.ts +++ b/packages/compiler-sfc/src/compileScript.ts @@ -1818,6 +1818,8 @@ function resolveTemplateUsageCheckString(sfc: SFCDescriptor, isTS: boolean) { if (value) { code += `,${processExp(value, isTS, baseName)}` } + } else if (name === 'ref') { + code += `,${value}` } } }, diff --git a/packages/compiler-sfc/test/__snapshots__/compileScript.spec.ts.snap b/packages/compiler-sfc/test/__snapshots__/compileScript.spec.ts.snap index 601abd2ee21..4b81610a48d 100644 --- a/packages/compiler-sfc/test/__snapshots__/compileScript.spec.ts.snap +++ b/packages/compiler-sfc/test/__snapshots__/compileScript.spec.ts.snap @@ -364,6 +364,20 @@ return { vMyDir } })" `; +exports[`SFC compile + + `) + expect(content).toMatch(`return { aref }`) + assertCode(content) + }) + test('vue interpolations', () => { const { content } = compile(`