安装

npm i element-ui 

在入口文件中引入

import ElementUI from 'element-ui';

import 'element-ui/lib/theme-chalk/index.css';

按需引入

借助 babel-plugin-component 我们可以只引入需要的组件,以达到减小项目体积的目的。

npm install babel-plugin-component -D

 

接下来,如果你只希望引入部分组件,比如 Button 和 Select,那么需要在 main.js 中写入以下内容:

import { Button, Select } from 'element-ui';
Vue.use(Button) Vue.use(Select)
这样就可以在组件中使用Button,和Select组件了
<el-button type="text">文字按钮</el-button>
posted on 2021-11-03 14:41  ygdong  阅读(138)  评论(0)    收藏  举报