学无先后,达者为师

网站首页 编程语言 正文

安装element UI (全局引入与按需引入)

作者:第1006号小白 更新时间: 2022-02-11 编程语言

安装element UI

全局引入

终端输入

npm i element-ui -S

在这里插入图片描述

import Vue from 'vue';
import ElementUI from 'element-ui';
import 'element-ui/lib/theme-chalk/index.css';
import App from './App.vue';

Vue.use(ElementUI);

new Vue({
  el: '#app',
  render: h => h(App)
});

在这里插入图片描述
这是我的
在这里插入图片描述
在helloworld里面添加一个
<el-button>按钮</el-button>可以明显看到效果
在这里插入图片描述

按需引入

在这里插入图片描述
终端输入

npm install babel-plugin-component -D

这里根据你的需要,比如我们这要用一个button控件,我引入的就是button
在这里插入图片描述
官网提示
在这里插入图片描述
这是我的

在这里插入图片描述

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

运行之后与全局引入有一样的效果,但是可以帮助我们减少项目的大小
如果此时加上radio这个控件
在这里插入图片描述
对引入需要修改
在这里插入图片描述

原文链接:https://blog.csdn.net/weixin_45626404/article/details/122824747

栏目分类
最近更新