vue我的项目elment按需导入

1.开发环境 vue+element
2.电脑系统 windows10专业版
3.在应用 vue+element开发的的过程中,咱们可能只是应用element-ui的几个组件,如果咱们把整个element-ui引入的话,就会导致我的项目过大。上面是element-ui按需导入的办法,心愿对你有所帮忙。
4.在终端执行命令:

npm add element-uinpm install babel-plugin-component -D

5.在babel.config.js增加如下代码:

module.exports = {  presets: [    '@vue/app'  ],  "plugins":[    [      "component",      {        "librayName":"element-ui",        "styleLibraryName":"theme-chalk"      }    ]  ]}

6.在main.js中增加如下代码:

import {Button,Progress} from 'element-ui';Vue.use(Button);Vue.use(Progress);

7.在vue模板中应用:

<el-button type="success" round>胜利按钮</el-button>    <el-progress :text-inside="true" :stroke-width="26" :percentage="70"></el-progress>


8.本期分享到了这里就完结啦,是不是很nice,心愿对你有所帮忙,让咱们一起致力走向巅峰!