{{format('0')}} {{format('338')}} {{format('1290')}}

【Vue】Vue 结合 Element UI [ 编程杂谈 ]

大数据男孩 文章 正文

想做一个技术博客,奈何实力不够
分享

明妃

{{nature("2022-08-14 17:23:20")}}更新

Element UI 说明

Element UI 是饿了么团队基于 Vue 开发的前端框架,使用方便 简单

官方文档:https://element.eleme.cn/#/zh-CN/component

推荐使用 npm 的方式安装,它能更好地和 webpack 打包工具配合使用

npm i element-ui -S

引入 Element

操作 main.js

完整引入

打包体积会变的大一点

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);  # 使用 ElementUI

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

按照需要引入

借助 babel-plugin-component 我们可以只引入需要的组件,以达到减小项目体积的目的。

npm install babel-plugin-component -D

修改 .babelrc 文件

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

接下来就能安装需要引入组件

import Vue from 'vue';
import { Button, Select } from 'element-ui';
import App from './App.vue';

Vue.component(Button.name, Button);
Vue.component(Select.name, Select);
/* 或写为
 * Vue.use(Button)
 * Vue.use(Select)
 */

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

官网有个完整单独组件引入 https://element.eleme.cn/#/zh-CN/component/quickstart

现在基于 Element 的环境开发搭建完毕

评论 0
0
{{userInfo.data?.nickname}}
{{userInfo.data?.email}}
TOP 2
Spark 2.0 单机模式与集群模式 安装

{{nature('2020-01-02 16:47:07')}} {{format('12518')}}人已阅读

TOP 3
Office 2016 Pro Plus 激活

{{nature('2019-12-11 20:43:10')}} {{format('9407')}}人已阅读

TOP 4
Linux上 MySQL 开启远程登陆的两种方法

{{nature('2019-12-26 17:20:52')}} {{format('7400')}}人已阅读

TOP 5
Linux 安装 MySQL 5.7

{{nature('2019-12-26 16:03:55')}} {{format('4877')}}人已阅读

目录

标签云

Vue Element UI

一言

# {{hitokoto.data.from || '来自'}} #
{{hitokoto.data.hitokoto || '内容'}}
作者:{{hitokoto.data.from_who || '作者'}}
自定义UI
配色方案

侧边栏