Browse Source

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

Co-authored-by: 三咲智子 Kevin Deng <sxzz@sxzz.moe>
白雾三语 2 years ago
parent
commit
9e031275d7
2 changed files with 2 additions and 3 deletions
  1. 1 1
      packages/runtime-vapor/src/component.ts
  2. 1 2
      packages/runtime-vapor/src/render.ts

+ 1 - 1
packages/runtime-vapor/src/component.ts

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

+ 1 - 2
packages/runtime-vapor/src/render.ts

@@ -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))