Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Cannot read properties of undefined (reading '$createElement') #943

Closed
qiYuei opened this issue Jun 17, 2022 · 2 comments
Closed

Cannot read properties of undefined (reading '$createElement') #943

qiYuei opened this issue Jun 17, 2022 · 2 comments

Comments

@qiYuei
Copy link

qiYuei commented Jun 17, 2022

Create projects with Vuecli5 ,When writing a jsx function in setup, h = this.$createElement will be automatically injected, but there is no this in setup, and h has been injected import {h} from '@vue/composition-api'

Console error message
image

image

version
[platform]:window10
[node]:14.16.1
"@vue/composition-api": "^1.6.1"
"@vue/babel-helper-vue-jsx-merge-props": "^1.2.1",
"@vue/babel-preset-jsx": "^1.2.4",

// babel.config.js
module.exports = {
  presets: [
    "@vue/cli-plugin-babel/preset",
    ["@vue/babel-preset-jsx", { compositionAPI: true }], // 开启 jsx
  ],
  plugins: [
    ["@babel/plugin-transform-typescript", { isTSX: true }], // 开启 typescript
    "@babel/plugin-proposal-optional-chaining",
  ],
};
@Mr-xzq
Copy link

Mr-xzq commented Jun 27, 2022

vuejs/jsx-vue2#183

  presets: [
    [
      '@vue/cli-plugin-babel/preset',
      {
        jsx: {
          compositionAPI: true,
        },
      },
    ],
  ],

@github-actions
Copy link

Stale issue message

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

2 participants