Cannot read properties of undefined (reading '$createElement')
qiYuei opened this issue · comments
Aymoc commented
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'
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",
],
};
xzq commented
presets: [
[
'@vue/cli-plugin-babel/preset',
{
jsx: {
compositionAPI: true,
},
},
],
],
github-actions commented
Stale issue message