fix: throw error without `script` block (#61)

Co-authored-by: 三咲智子 Kevin Deng <sxzz@sxzz.moe>
This commit is contained in:
白雾三语 2023-12-13 15:16:33 +08:00 committed by GitHub
parent 5e681b5945
commit 9e031275d7
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
2 changed files with 2 additions and 3 deletions

View File

@ -20,7 +20,7 @@ export type FunctionalComponent = SetupFn & {
}
export interface ObjectComponent {
props: ComponentPropsOptions
setup: SetupFn
setup?: SetupFn
render(ctx: any): Block
}

View File

@ -50,11 +50,10 @@ export function mountComponent(
const setupFn =
typeof component === 'function' ? component : component.setup
const state = setupFn(props, ctx)
instance.proxy = markRaw(
new Proxy({ _: instance }, PublicInstanceProxyHandlers),
)
const state = setupFn && setupFn(props, ctx)
if (state && '__isScriptSetup' in state) {
instance.setupState = proxyRefs(state)
return (instance.block = component.render(instance.proxy))