在Vue项目中使用Element组件

0 写在前面

使用组件可以快速进行开发,使用Element UI轻松制作出网页,为前端开发人员大大减轻了代码负担,即使是后端程序员也可以快速上手做出比较精美的界面。
本文记录如何在Vue项目中使用Element。

1 安装

推荐使用npm i element-ui -S命令直接下载。
图文演示:(本文是在WebStream下演示,一下与软件无关,使用任何地方的终端结果都是一样的)
在创建好的Vue目录下直接输入命令npm i element-ui -S
在这里插入图片描述

在这里插入图片描述
出现element -ui@版本号就代表安装成功了。

2 配置

在根目录下的main.js中作以下配置

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

Vue.use(ElementUI);

new Vue({
    store,
    mainPage,
    render: function (h) {
        return h(App)
    }
}).$mount('#app')

重点就是引用并使用

import ElementUI from 'element-ui';
Vue.use(ElementUI);

在这里插入图片描述

3 使用组件

打开Element-网站快速成型工具选择组件
在这里插入图片描述
选择自己需要的组件
在这里插入图片描述
这里以按钮为例
在这里插入图片描述
它们所对应的代码为:

<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>

<el-row>
  <el-button plain>朴素按钮</el-button>
  <el-button type="primary" plain>主要按钮</el-button>
  <el-button type="success" plain>成功按钮</el-button>
  <el-button type="info" plain>信息按钮</el-button>
  <el-button type="warning" plain>警告按钮</el-button>
  <el-button type="danger" plain>危险按钮</el-button>
</el-row>

<el-row>
  <el-button round>圆角按钮</el-button>
  <el-button type="primary" round>主要按钮</el-button>
  <el-button type="success" round>成功按钮</el-button>
  <el-button type="info" round>信息按钮</el-button>
  <el-button type="warning" round>警告按钮</el-button>
  <el-button type="danger" round>危险按钮</el-button>
</el-row>

<el-row>
  <el-button icon="el-icon-search" circle></el-button>
  <el-button type="primary" icon="el-icon-edit" circle></el-button>
  <el-button type="success" icon="el-icon-check" circle></el-button>
  <el-button type="info" icon="el-icon-message" circle></el-button>
  <el-button type="warning" icon="el-icon-star-off" circle></el-button>
  <el-button type="danger" icon="el-icon-delete" circle></el-button>
</el-row>

举例:

<template>
  <el-row>
    <el-button>我是默认按钮</el-button>
    <el-button type="primary">蓝色的按钮</el-button>
    <el-button type="success" plain>plain代表朴素</el-button>
    <el-button type="info" round>round能改变为圆角</el-button>
    <el-button type="warning"round plain>警告按钮</el-button>
    <el-button type="danger">危险危险危险</el-button>
  </el-row>
</template>

启动后:
在这里插入图片描述

4 写在最后

以上为安装,配置,使用的方法,在此简单记录一下。

评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值