一、 安装element-ui
npm install element-ui --save
因为element-ui是依赖于element,所以也需要安装此
npm install element --save
二、 npm install babel-plugin-component -D
三、 在babel.config.js中添加此段代码
如有其它配置,只需要在 plugins 的数组中继续添加我们需要的配置代码就行了
module.exports = {
plugins: [
[
'component',
{
libraryName: 'element-ui',
styleLibraryName: 'theme-chalk'
}
]
]
}
四、 可以在项目文件下添加plugins文件,并添加element.js
//按照自己需要添加组件
import Vue from 'vue'
import { Button, Form, FormItem, Input, Message } from 'element-ui';
import 'element-ui/lib/theme-chalk/index.css'
Vue.use(Button).use(Form).use(FormItem).use(Input)
Vue.prototype.$message = Message
五、 最后在main.js中导入
import '@/plugins/element.js'