Movatterモバイル変換


[0]ホーム

URL:


Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Sign up
Appearance settings
/vuePublic

Commit83d9535

Browse files
authored
fix(compiler-sfc): check templateref usage, (#12985)
close#12984
1 parent24fcf69 commit83d9535

File tree

3 files changed

+29
-0
lines changed

3 files changed

+29
-0
lines changed

‎packages/compiler-sfc/src/compileScript.ts

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1818,6 +1818,8 @@ function resolveTemplateUsageCheckString(sfc: SFCDescriptor, isTS: boolean) {
18181818
if(value){
18191819
code+=`,${processExp(value,isTS,baseName)}`
18201820
}
1821+
}elseif(name==='ref'){
1822+
code+=`,${value}`
18211823
}
18221824
}
18231825
},

‎packages/compiler-sfc/test/__snapshots__/compileScript.spec.ts.snap

Lines changed: 14 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -364,6 +364,20 @@ return { vMyDir }
364364
})"
365365
`;
366366
367+
exports[`SFC compile <scriptsetup> > dev mode import usage check > imported ref as template ref 1`] = `
368+
"import{defineComponentas_defineComponent} from 'vue'
369+
import{aref} from './x'
370+
371+
export default /*#__PURE__*/_defineComponent({
372+
setup(__props) {
373+
374+
375+
return {aref }
376+
}
377+
378+
})"
379+
`;
380+
367381
exports[`SFC compile <scriptsetup> > dev mode import usage check > js template string interpolations 1`] = `
368382
"import{defineComponentas_defineComponent} from 'vue'
369383
import{VAR,VAR2,VAR3} from './x'

‎packages/compiler-sfc/test/compileScript.spec.ts

Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -398,6 +398,19 @@ defineExpose({ foo: 123 })
398398
assertCode(content)
399399
})
400400

401+
test('imported ref as template ref',()=>{
402+
const{ content}=compile(`
403+
<script setup lang="ts">
404+
import { aref } from './x'
405+
</script>
406+
<template>
407+
<div ref="aref"></div>
408+
</template>
409+
`)
410+
expect(content).toMatch(`return { aref }`)
411+
assertCode(content)
412+
})
413+
401414
test('vue interpolations',()=>{
402415
const{ content}=compile(`
403416
<script setup lang="ts">

0 commit comments

Comments
 (0)

[8]ページ先頭

©2009-2025 Movatter.jp