详情请点击

一、安装

  1. yarn add element-ui 或者
  2. npm i element-ui -S

二、引入elment

main.js中

  1. import Vue from 'vue';
  2. import ElementUI from 'element-ui';
  3. import 'element-ui/lib/theme-chalk/index.css';
  4. import App from './App.vue';
  5. Vue.use(ElementUI);
  6. new Vue({
  7. el: '#app',
  8. render: h => h(App)
  9. });

三、按需引入

3-1 先安装babel-plugin-component

  1. yarn add babel-plugin-component -D

3-2 修改babel.config.js

  1. module.exports = {
  2. presets: [
  3. '@vue/cli-plugin-babel/preset'
  4. ],
  5. "plugins": [
  6. [
  7. "component",
  8. {
  9. "libraryName": "element-ui",
  10. "styleLibraryName": "theme-chalk"
  11. }
  12. ]
  13. ]
  14. }

3-3 按需引入

  1. import { Button } from 'element-ui';
  2. Vue.use(Button)