按需引入 Element 组件

  • 首先,安装 babel-plugin-component:
npm install babel-plugin-component -D
  • 然后,将 babelrc.config.js修改为:
module.exports = {
  presets: ['@vue/cli-plugin-babel/preset', ['@babel/preset-env', { modules: false }]],
  plugins: [
    [
      'component',
      {
        libraryName: 'element-ui',
        styleLibraryName: 'theme-chalk',
      },
    ],
  ],
}

  • 创建plugins/element.js
import Vue from 'vue'
import { Button, Select } from 'element-ui'

Vue.use(Button).use(Select)

  • 创建plugins/index.js
import './element.js'
  • main.js引入
import './plugins/index.js' // 引入插件
posted @   天使阿丽塔  阅读(142)  评论(0编辑  收藏  举报
相关博文:
阅读排行:
· 阿里最新开源QwQ-32B,效果媲美deepseek-r1满血版,部署成本又又又降低了!
· 单线程的Redis速度为什么快?
· SQL Server 2025 AI相关能力初探
· AI编程工具终极对决:字节Trae VS Cursor,谁才是开发者新宠?
· 展开说说关于C#中ORM框架的用法!
点击右上角即可分享
微信分享提示