全局引入elementUI
import ElementUI from ‘element-ui’;
import ‘element-ui/lib/theme-chalk/index.css’;
Vue.use(ElementUI);
按需引入elementUI
先下载插件 npm install babel-plugin-component -D
修改babel.config.js文件
plugins: [
[
'component',
{
libraryName: 'element-ui',
styleLibraryName: 'theme-chalk'
},
],
],`
import { Button } from ‘element-ui’;
import ‘element-ui/lib/theme-chalk/index.css’;
Vue.use(Button);

本文介绍如何在Vue项目中全局引入ElementUI组件库,以及如何通过Babel插件实现ElementUI的按需加载,减少项目打包体积。
2002

被折叠的 条评论
为什么被折叠?



