babel-plugin-component icon indicating copy to clipboard operation
babel-plugin-component copied to clipboard

使用 import { Button as Ebutton } from 'element-ui' 报错

Open g0ne150 opened this issue 7 years ago • 3 comments

使用 import { Button as Ebutton } from 'element-ui' 报错 报错内容如图 image babelrc 配置

{
    "presets": [],
    "plugins": [
        "transform-vue-jsx",
        ["component",[{
            "libraryName": "element-ui",
            "styleLibraryName": "theme-default"
          }]]]
}

webpack 版本 2.4.1

g0ne150 avatar Apr 18 '17 02:04 g0ne150

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

yoyo837 avatar Oct 28 '17 15:10 yoyo837

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

zzx18023 avatar Nov 21 '18 03:11 zzx18023

你应该是用了两种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

gucovip avatar Dec 26 '18 09:12 gucovip