]> git.ipfire.org Git - thirdparty/vuejs/core.git/commitdiff
fix: throw error without `script` block (#61)
author白雾三语 <32354856+baiwusanyu-c@users.noreply.github.com>
Wed, 13 Dec 2023 07:16:33 +0000 (15:16 +0800)
committerGitHub <noreply@github.com>
Wed, 13 Dec 2023 07:16:33 +0000 (15:16 +0800)
Co-authored-by: 三咲智子 Kevin Deng <sxzz@sxzz.moe>
packages/runtime-vapor/src/component.ts
packages/runtime-vapor/src/render.ts

index 5ff3b86b8ff720f7f46912701c3ff5505afc7fc8..68e3c6942fcf2a859f77fcdbfc7adbff7f3ca34a 100644 (file)
@@ -20,7 +20,7 @@ export type FunctionalComponent = SetupFn & {
 }
 export interface ObjectComponent {
   props: ComponentPropsOptions
-  setup: SetupFn
+  setup?: SetupFn
   render(ctx: any): Block
 }
 
index 422d5e689e02c59d6c0a44682b872e0f6803d793..f55acd5760b5398557b8c8311ad6d688c11591bd 100644 (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))