Skip to content

Use "@vue/compiler-sfc" to get a root component, but the _ctx of render function doesn't have any my variable and throw a reading undefined error. #8964

Discussion options

You must be logged in to vote

I looked at the source code, and mode setup requires the bindings (compilerOptions.bindingMetadata).

      const filename = file.split('/').slice(-1)[0];
      const sfc = compilerSfc(source);
      const {
        content: componentRaw,
        scriptAst,
        scriptSetupAst,
        setup: isSetup,
        bindings, // HERE
      } = compileScript(sfc.descriptor, {
        id,
        genDefaultAs: '__component',
      });

      const template = compileTemplate({
        filename,
        id,
        scoped: true,
        source: sfc.descriptor.template.content,
        compilerOptions: {
          bindingMetadata: bindings,  //HERE
        },
      } as SFCTemplateCompileOptions).code

Replies: 1 comment

Comment options

You must be logged in to vote
0 replies
Answer selected by lolosiax
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
1 participant
Converted from issue

This discussion was converted from issue #8963 on August 13, 2023 16:15.