一、安装
yarn add element-ui 或者
npm i element-ui -S
二、引入elment
main.js中
import Vue from 'vue';
import ElementUI from 'element-ui';
import 'element-ui/lib/theme-chalk/index.css';
import App from './App.vue';
Vue.use(ElementUI);
new Vue({
el: '#app',
render: h => h(App)
});
三、按需引入
3-1 先安装babel-plugin-component
yarn add babel-plugin-component -D
3-2 修改babel.config.js
module.exports = {
presets: [
'@vue/cli-plugin-babel/preset'
],
"plugins": [
[
"component",
{
"libraryName": "element-ui",
"styleLibraryName": "theme-chalk"
}
]
]
}
3-3 按需引入
import { Button } from 'element-ui';
Vue.use(Button)