vue-cli-3+element-ui 按需引入element-ui的配置

Posted on 2020-06-28 10:53  凡凡0410  阅读(402)  评论(0编辑  收藏  举报

需要安装的

cnpm install element-ui -S

cnpm install  babel-plugin-import --save

npm install babel-plugin-component -D

然后在babel.config.js中

module.exports = {
  presets: [
    ["@babel/preset-env", { "modules": false }]
  ],
  "plugins": [
    [
      "component",
      {
        "libraryName": "element-ui",
        "styleLibraryName": "theme-chalk"
      }
    ]
  ]
}

在main.js中

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

 

Copyright © 2024 凡凡0410
Powered by .NET 9.0 on Kubernetes