feat(sfc): support resolving template components from <script setup> exports

This commit is contained in:
Evan You 2020-07-28 17:31:46 -04:00
parent aa06b1034d
commit 6f5d840612
2 changed files with 12 additions and 2 deletions

View File

@ -244,7 +244,12 @@ export function resolveComponentType(
return builtIn
}
// 3. user component (resolve)
// 3. user component (from setup bindings)
if (context.bindingMetadata[tag] === 'setup') {
return `$setup[${JSON.stringify(tag)}]`
}
// 4. user component (resolve)
context.helper(RESOLVE_COMPONENT)
context.components.add(tag)
return toValidAssetId(tag, `component`)

View File

@ -10,7 +10,12 @@ export const compilerOptions: CompilerOptions = reactive({
hoistStatic: false,
cacheHandlers: false,
scopeId: null,
ssrCssVars: `{ color }`
ssrCssVars: `{ color }`,
bindingMetadata: {
TestComponent: 'setup',
foo: 'setup',
bar: 'props'
}
})
const App = {