Comments (15)
@iwangx if you use vue-cli to create your project,then you should toggle the injectH
feature in @vue/app
jsx options like this
module.exports = {
presets: [
[
"@vue/app",
{
useBuiltIns: "entry",
jsx: {
injectH: false
}
}
]
]
};
from jsx-vue2.
@iwangx, just to fix it for the moment you can disable injectH
in babel config like this:
{
"presets": [
[
"@vue/babel-preset-jsx",
{
"injectH": false
}
]
]
}
from jsx-vue2.
So when I npm run serve
,console log
Module build failed (from ./node_modules/babel-loader/lib/index.js):
TypeError: /Users/***/view.vue: Duplicate declaration "h" (This is an error on an internal node. Probably an internal error.)
from jsx-vue2.
@iwangx, since you use weird h
passing around, we probably don't want to support this, but you can build this project if you turn it off, you can do it by using this babel
config:
module.exports = {
presets: [
['@vue/babel-preset-jsx', {
injectH: false
}],
['@vue/app', {
useBuiltIns: 'entry'
}],
],
'plugins': [
[ 'component', {
'libraryName': 'element-ui',
'styleLibraryName': 'theme-chalk'
} ],
]
};
from jsx-vue2.
@iwangx, to make it simpler, can you please create a basic reproduction repository on github?
from jsx-vue2.
@nickmessing it ok.but a new error was added
[Vue warn]: Error in data(): "TypeError: Cannot read property '$createElement' of undefined"
from jsx-vue2.
@nickmessing
https://github.com/iwangx/jsx-example
from jsx-vue2.
@iwangx, thank you for the reproduction, I'll check it once I get to my computer
from jsx-vue2.
@nickmessing , I don't think plug-ins should define 'h' by themselves. Usually, we define 'h' by ourselves and look for the variable 'h' from the nearest scope.
from jsx-vue2.
When you turned off injectH
it's disabled so there are two different bugs involved, probably... Not just the h
injection
from jsx-vue2.
So I hope you can solve this problem as soon as possible.
from jsx-vue2.
@nickmessing
The problem still exists.
[Vue warn]: Error in data(): "TypeError: Cannot read property '$createElement' of undefined"
from jsx-vue2.
@iwangx, I just changed babel config to the one I provided in your repo and it builds fine...
from jsx-vue2.
@nickmessing But this error will be output in the browser console
from jsx-vue2.
Some tool like storybook for vue has its own configuration so you need remove babel-plugin-transform-vue-jsx
plugin in your babel config like in babel.config.js
.
export TARGET=story && npm run storybook
In babel.config.js
:
// only add this plugin if it is not in storybook mode.
if (process.env.TARGET !== 'story') {
module.exports.plugin.push( `babel-plugin-transform-vue-jsx` );
}
from jsx-vue2.
Related Issues (20)
- jsx cannot modify array in data
- Error in binding keyboard
- To give a ref to the JSX Element but I cannot get it by $refs. why?
- Include License File
- Vue 2.7 compatibility HOT 6
- 无法在vue2.7的setup中使用jsx HOT 17
- 无法在vue2.7的中使用ref获取dom,以及组件实例。 HOT 4
- scoped css not working with compositionAPI enabled and functional component using render HOT 1
- 迁移composition-api过程中无法兼容method和setup的injectH
- 创建的jsx文件导入到另一jsx中,导出小写不提示,大写提示非jsx HOT 1
- jsx 无法监听鼠标移入移除事件
- 两个preset都使用“sugar-inject-h”这个插件导致duplicate declaration h HOT 1
- 我用 map return 一组 tag div, 每个 div 中再用 ref 标记一个组件,最后得到的是一个 object, 我希望的到的是数组 HOT 3
- web component slot not work
- i want to know that how to use v-slot instead slot directive in jsx-vue2 HOT 4
- v-model compile error on playgroud
- bug:显式import render函数时不应该将其转化为h() , 请在转换时判断是否在vue组件的上下文中,或者是否是vue格式文件
- Modifiers _capture doesn't work with el-col of ElementUi HOT 2
- Cannot parse a prop that starts with _
- 在 Rspack 中无法正常工作
Recommend Projects
-
React
A declarative, efficient, and flexible JavaScript library for building user interfaces.
-
Vue.js
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
-
Typescript
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
-
TensorFlow
An Open Source Machine Learning Framework for Everyone
-
Django
The Web framework for perfectionists with deadlines.
-
Laravel
A PHP framework for web artisans
-
D3
Bring data to life with SVG, Canvas and HTML. 📊📈🎉
-
Recommend Topics
-
javascript
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
-
web
Some thing interesting about web. New door for the world.
-
server
A server is a program made to process requests and deliver data to clients.
-
Machine learning
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
-
Visualization
Some thing interesting about visualization, use data art
-
Game
Some thing interesting about game, make everyone happy.
Recommend Org
-
Facebook
We are working to build community through open source technology. NB: members must have two-factor auth.
-
Microsoft
Open source projects and samples from Microsoft.
-
Google
Google ❤️ Open Source for everyone.
-
Alibaba
Alibaba Open Source for everyone
-
D3
Data-Driven Documents codes.
-
Tencent
China tencent open source team.
from jsx-vue2.