ElementUI / babel-plugin-component

Modular element-ui build plugin for babel.
452 stars 96 forks source link

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

Open g0ne150 opened 7 years ago

g0ne150 commented 7 years ago

使用 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

yoyo837 commented 7 years ago

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:

To install them, you can run: npm install --save antd/lib/e-m-b antd/lib/m-m-b

zzx18023 commented 5 years ago

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:

gucovip commented 5 years ago

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