使用ElementUI组件库

引入ElementUI组件库

1.安装插件

复制代码
npm i element-ui -S

2.引入组件库

复制代码
import ElementUI from 'element-ui';

3.引入全部样式

复制代码
import 'element-ui/lib/theme-chalk/index.css';

4.使用

复制代码
Vue.use(ElementUI);

5.在官网寻找所需样式

饿了么组件官网 我这里以button为例

6.在组件中使用

复制代码
    <el-row>
      <el-button>默认按钮</el-button>
      <el-button type="primary">主要按钮</el-button>
      <el-button type="success">成功按钮</el-button>
      <el-button type="info">信息按钮</el-button>
      <el-button type="warning">警告按钮</el-button>
      <el-button type="danger">危险按钮</el-button>
    </el-row>

按需引入

1.安装插件

复制代码
npm install babel-plugin-component -D

2.引入

复制代码
import { Button,Row } from 'element-ui';

3.使用并命名

复制代码
Vue.component(Button.name, Button)
Vue.component('rrr', Row)

4.修改babel.config.js

复制代码
module.exports = {
  presets: [
    '@vue/cli-plugin-babel/preset',
    ["@babel/preset-env", { "modules": false }],
  ],
  plugins: [
    [
      "component",
      {
        "libraryName": "element-ui",
        "styleLibraryName": "theme-chalk"
      }
    ]
  ]
}

5.如果我们在命名时自定义了名字那么使用的时候就需要使用我们自定义的名字

复制代码
    <rrr>
      <el-button>默认按钮</el-button>
      <el-button type="primary">主要按钮</el-button>
      <el-button type="success">成功按钮</el-button>
      <el-button type="info">信息按钮</el-button>
      <el-button type="warning">警告按钮</el-button>
      <el-button type="danger">危险按钮</el-button>
    </rrr>

6.如果启动时说却什么就通过npm i 进行安装

复制代码
npm i
相关推荐
鱼与宇1 天前
Element-plus离线访问(适用内网)
elementui·vue3
weixin_422555422 天前
el-menu子菜单点击就被激活,恢复之前的激活状态
javascript·vue.js·elementui
yume_sibai2 天前
Element Plus 导航与反馈组件完全指南(15个核心组件)
前端·elementui·交互
XLYcmy7 天前
HTML/CSS/JS 基础与 Vue 技术栈深度解析
java·前端·css·html·vue3·vue2·api
雪芽蓝域zzs8 天前
第十节:动态侧边栏菜单(根据路由 meta 自动渲染菜单)
javascript·vue.js·elementui
m0_5791466512 天前
Element UI 表格合并单元格完全指南:从原理到实战
前端·vue.js·elementui
常宇佳14 天前
vue3 实战系列之踩过的一些坑
javascript·vue.js·elementui
aXin_ya17 天前
ElementUI (01):Vue2 项目引入 ElementUI使用
elementui·vue
山川志~17 天前
Vue + Element UI 实战:如何实现表格时间、金额字段排序
vue.js·ui·elementui
Sterting25 天前
Form表单与校验
javascript·vue.js·elementui