一、element-ui 按需引入
npm i element-ui -S
npm install babel-plugin-component -D
1. 修改babel.config.js文件:
module.exports = {
// 源代码
presets: [
'@vue/cli-plugin-babel/preset'
],
// 添加代码项
plugins: [
[
'component',
{
libraryName: 'element-ui',
styleLibraryName: 'theme-chalk'
}
]
]
}
2. 在main.js文件引入想要使用的组件:
import Vue from 'vue'
import App from './App.vue'
import router from './router'
import store from './store'
import { Message, MessageBox } from 'element-ui'
Vue.config.productionTip = false
Vue.prototype.$message = Message
Vue.prototype.$MessageBox =