babel-plugin-component
babel-plugin-component copied to clipboard
使用 import { Button as Ebutton } from 'element-ui' 报错
使用 import { Button as Ebutton } from 'element-ui'
报错
报错内容如图
babelrc 配置
{
"presets": [],
"plugins": [
"transform-vue-jsx",
["component",[{
"libraryName": "element-ui",
"styleLibraryName": "theme-default"
}]]]
}
webpack 版本 2.4.1
The same.
import {Loading, MessageBox as EMB} from 'element-ui'
import {Indicator, Toast, MessageBox as MMB} from 'mint-ui'
It report: These dependencies were not found:
- antd/lib/e-m-b in ./components/popup.js
- antd/lib/m-m-b in ./components/popup.js
To install them, you can run: npm install --save antd/lib/e-m-b antd/lib/m-m-b
babel.config.js
module.exports = {
presets: ['@vue/app'],
plugins: [
[
'component',
{
libraryName: 'mint-ui',
style: true
},
'mint-ui'
],
[
'component',
{
libraryName: 'element-ui',
styleLibraryName: 'theme-chalk'
},
'element-ui'
]
]
}
script
import { Button as mtButton } from 'mint-ui'
import { Button as elButton } from 'element-ui'
These dependencies were not found:
- element-ui/lib/el-button
- mint-ui/lib/mt-button
你应该是用了两种ui框架,同时引入了两个Button组件。 我的解决方案是:建两个文件去分别引入 ui.el.js: import { Button } from 'element-ui'; ui.mint.js: import { Button } from 'mint-ui'; 然后再引入他们 import './ui.el'; import './ui.mint'; 你会发现问题解决了 @g0ne150 @zzx18023 @yoyo837