vue引入Element-UI

最近使用vue脚手架搭建了一个后台管理系统并引入了element-ui

引入element-ui推荐使用npm

npm i element-ui -S

如果是全局引入就在main.js中

import  ElementUI from 'element-ui' 

也可以引入部分这样不需要的部分就不会加载,前提要安装babel-plugin-component:

npm install babel-plugin-component -D

然后改.babelrc文件

{
  "presets": [["es2015", { "modules": false }]],
  "plugins": [
    [
      "component",
      {
        "libraryName": "element-ui",
        "styleLibraryName": "theme-chalk"
      }
    ]
  ]
}

然后再引入的时候就可以按照需要来引入,比如:

import { Button, Select } from 'element-ui';

这时候就可以在我们的项目里使用已经引用的element-ui了。可以结合官方的文档来进行使用。


猜你喜欢

转载自blog.csdn.net/mo_jiu/article/details/80340071