Vue开发实例(四)Element-UI部分组件使用方法

news2024/9/30 7:19:45

Element-UI的使用

  • 一、Icon图标的使用
    • 1、用 i 标签使用图标
  • 二、用 el-button 使用图标
    • 1、使用type定义样式
    • 2、使用plain定义样式
    • 3、使用round定义样式
    • 4、使用circle定义样式
    • 5、带图标和文字的按钮
    • 6、按钮禁用
    • 7、文字按钮
    • 8、按钮组
    • 9、加载中
  • 三、Link 文字链接
    • 1、基础用法
    • 2、禁用
    • 3、下划线
    • 4、图标

一、Icon图标的使用

Element提供了丰富的图标,基本能够满足日常的使用,可以到官网去查看。

在这里插入图片描述

1、用 i 标签使用图标

使用格式如下:

<i class=“el-icon-XXX”></i>

这里的XXX表示图标名,比如编辑用的 “edit” 用户头像的"user"

<div>
    <i class="el-icon-edit"></i>
    <i class="el-icon-user"></i>
</div>

在这里插入图片描述
可以通过样式来改变图标的大小和颜色,比如我们来修改一下user的大小和颜色,在style中加入样式

<style scoped>
    .el-icon-user{
        font-size: 30px;
        color: green;
    }
</style>

效果如下:
在这里插入图片描述

二、用 el-button 使用图标

按钮这在web开发中是非常常见的,这里就看看element按钮的一些使用方式

使用格式如下:

<el-button type=“primary” class=“el-icon-XXX”>按钮名称</el-button>
  1. 可以使用type、plain、round和circle属性来定义 Button 的样式
  2. type="primary"也可以不要,但是没那么好看,建议加上
  3. XXX表示图标的名字
  4. 按钮名称自己定义

在template中加入el-button代码

<div>
    <el-button type="primary" class="el-icon-search">查询</el-button>
</div>

在这里插入图片描述
同样的也可以改样式

.el-icon-search{
   font-size: 20px;
    color: black;
}

1、使用type定义样式

type可以分为:primary、success、info、warning、danger
设定不同的type将会显示不同的颜色,如果type没有设定,或者设定的值不是这5个里面的,则会是默认没有颜色的按钮。

在这里插入图片描述

<template>
    <div>
        <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>
    </div>
</template>

在这里插入图片描述

2、使用plain定义样式

plain是一种使用简单的纯色样式,使用时候,只要加上这个属性即可,默认就是true

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

在这里插入图片描述

3、使用round定义样式

就是将按钮变成圆角

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

在这里插入图片描述

4、使用circle定义样式

circle属性就是让按钮显示为圆形,加入circle试试

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

在这里插入图片描述
虽然实现了圆形按钮,但是我们发现这个圆形,不太圆,是因为文字太多导致比较长,于是我把最后一个按钮的名字“危险按钮”改成“危”,按钮确实变圆了。
在这里插入图片描述
但是项目中,很显然这种图标不是我们需要的,就一个字,我哪里知道是什么意思呢,于是我们想到是不是可以用图标来代替,图标我们还是很容易看懂它表示的意思,修改如下:

加入图标 class=“el-icon-XXX”
删除按钮名称

修改一部分代码

<el-button type="warning" circle class="el-icon-search"></el-button>
<el-button type="danger" circle class="el-icon-user"></el-button>

在这里插入图片描述

el-icon-user的变大,是因为之前的代码加了一个样式

5、带图标和文字的按钮

<el-row>
   <el-button type="primary" icon="el-icon-edit"></el-button>
   <el-button type="primary" icon="el-icon-share"></el-button>
   <el-button type="primary" icon="el-icon-delete"></el-button>
   <el-button type="primary" icon="el-icon-search">搜索</el-button>
   <el-button type="primary">上传<i class="el-icon-upload el-icon--right"></i></el-button>
</el-row>

在这里插入图片描述

6、按钮禁用

给按钮加上disabled属性即可,加上以后颜色也不一样了,鼠标移上去会显示不可用。

<el-row>
  <el-button type="primary" disabled>主要按钮</el-button>
  <el-button type="primary" plain disabled>主要按钮</el-button>
  <el-button type="primary" circle disabled>主要按钮</el-button>
  <el-button type="primary" icon="el-icon-delete" disabled></el-button>
  <el-button type="primary" icon="el-icon-search" disabled>搜索</el-button>
</el-row>

在这里插入图片描述

7、文字按钮

将type设置为text: type=“text”

 <el-row>
    <el-button type="text" >主要按钮1</el-button>
    <el-button type="text" plain >主要按钮2</el-button>
    <el-button type="text" circle >主要按钮3</el-button>
    <el-button type="text" icon="el-icon-delete" disabled></el-button>
    <el-button type="text" icon="el-icon-search" disabled>搜索</el-button>
</el-row>

在这里插入图片描述

8、按钮组

以按钮组的方式出现,常用于多项类似操作,比如分页中的上一页、下一页。

 <el-row>
   <el-button-group>
       <el-button type="primary" icon="el-icon-arrow-left">上一页</el-button>
       <el-button type="primary">下一页<i class="el-icon-arrow-right el-icon--right"></i></el-button>
   </el-button-group>
</el-row>

在这里插入图片描述

9、加载中

只要设置loading属性为true即可。
常用于搜索的时候,搜索完成后设置 loading为false,用vue很好控制。

<el-row>
    <el-button type="primary" :loading="true">加载中</el-button>
</el-row>

在这里插入图片描述

三、Link 文字链接

在这里插入图片描述

1、基础用法

 <div>
    <el-link href="https://www.baidu.com" target="_blank">默认链接</el-link>
     <el-link type="primary">主要链接</el-link>
     <el-link type="success">成功链接</el-link>
     <el-link type="warning">警告链接</el-link>
     <el-link type="danger">危险链接</el-link>
     <el-link type="info">信息链接</el-link>
 </div>

在这里插入图片描述

2、禁用

设置 disabled 属性即可

<div>
    <el-link href="https://www.baidu.com" target="_blank" disabled>默认链接</el-link>
    <el-link type="primary" disabled>主要链接</el-link>
    <el-link type="success" disabled>成功链接</el-link>
    <el-link type="warning" disabled>警告链接</el-link>
    <el-link type="danger" disabled>危险链接</el-link>
    <el-link type="info" disabled>信息链接</el-link>
</div>

在这里插入图片描述

3、下划线

当鼠标移动到链接文字的时候,会有下划线,如果我不想要这个下划线,加入underline属性设置为false即可,写法如下::underline=“false”

<div>
   <el-link href="https://www.baidu.com" target="_blank" :underline="false">默认链接</el-link>
   <el-link type="primary" :underline="false">主要链接</el-link>
   <el-link type="success" :underline="false">成功链接</el-link>
   <el-link type="warning" :underline="false">警告链接</el-link>
   <el-link type="danger" :underline="false">危险链接</el-link>
   <el-link type="info" :underline="false">信息链接</el-link>
</div>

在这里插入图片描述

4、图标

<el-link icon="el-icon-edit">编辑</el-link>
<el-link>查看<i class="el-icon-view el-icon--right"></i> </el-link>

在这里插入图片描述


基础的使用就介绍到这里,其他的使用方法参考官网;
官网地址:https://element.eleme.cn/#/zh-CN/component/installation


全部代码

<template>
  <div class="hello">
    <h1>{{ msg }}</h1>
    <el-button>这是一个按钮</el-button><br /><br />
    <i class="el-icon-edit"></i>
    <i class="el-icon-user"></i><br /><br />
    <el-button type="primary" class="el-icon-search">查询</el-button
    ><br /><br />
    <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>
    <br /><br />
    <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
    ><br /><br />
    <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
    ><br /><br />
    <el-row>
      <el-button circle>圆形按钮-文字</el-button>
      <el-button type="primary" circle>主要按钮</el-button>
      <el-button type="success" circle>成功按钮</el-button>
      <el-button type="info" circle>信息按钮</el-button>
      <el-button type="warning" circle class="el-icon-search"></el-button>
      <el-button type="danger" circle class="el-icon-user"></el-button> </el-row
    ><br /><br />
    <el-row>
      <el-button type="primary" icon="el-icon-edit"></el-button>
      <el-button type="primary" icon="el-icon-share"></el-button>
      <el-button type="primary" icon="el-icon-delete"></el-button>
      <el-button type="primary" icon="el-icon-search">搜索</el-button>
      <el-button type="primary"
        >上传<i class="el-icon-upload el-icon--right"></i
      ></el-button> </el-row
    ><br /><br />
    <el-row>
      <el-button type="primary" disabled>主要按钮</el-button>
      <el-button type="primary" plain disabled>主要按钮</el-button>
      <el-button type="primary" circle disabled>主要按钮</el-button>
      <el-button type="primary" icon="el-icon-delete" disabled></el-button>
      <el-button type="primary" icon="el-icon-search" disabled
        >搜索</el-button
      > </el-row
    ><br /><br />
    <el-row>
      <el-button type="text">主要按钮1</el-button>
      <el-button type="text" plain>主要按钮2</el-button>
      <el-button type="text" circle>主要按钮3</el-button>
      <el-button type="text" icon="el-icon-delete" disabled></el-button>
      <el-button type="text" icon="el-icon-search" disabled
        >搜索</el-button
      > </el-row
    ><br /><br />
    <el-row>
      <el-button-group>
        <el-button type="primary" icon="el-icon-arrow-left">上一页</el-button>
        <el-button type="primary"
          >下一页<i class="el-icon-arrow-right el-icon--right"></i
        ></el-button>
      </el-button-group> </el-row
    ><br /><br />
    <el-row>
      <el-button type="primary" :loading="true">加载中</el-button> </el-row
    ><br /><br />

    <el-link href="https://www.baidu.com" target="_blank">默认链接</el-link
    >&nbsp;&nbsp; <el-link type="primary">主要链接</el-link>&nbsp;&nbsp;
    <el-link type="success">成功链接</el-link>&nbsp;&nbsp;
    <el-link type="warning">警告链接</el-link>&nbsp;&nbsp;
    <el-link type="danger">危险链接</el-link>&nbsp;&nbsp;
    <el-link type="info">信息链接</el-link>&nbsp;&nbsp;<br /><br />

    <el-link href="https://www.baidu.com" target="_blank" disabled
      >默认链接</el-link
    >&nbsp;&nbsp;
    <el-link type="primary" disabled>主要链接</el-link>&nbsp;&nbsp;
    <el-link type="success" disabled>成功链接</el-link>&nbsp;&nbsp;
    <el-link type="warning" disabled>警告链接</el-link>&nbsp;&nbsp;
    <el-link type="danger" disabled>危险链接</el-link>&nbsp;&nbsp;
    <el-link type="info" disabled>信息链接</el-link>&nbsp;&nbsp;<br /><br />

    <el-link href="https://www.baidu.com" target="_blank" :underline="false"
      >默认链接</el-link
    >&nbsp;&nbsp;
    <el-link type="primary" :underline="false">主要链接</el-link>&nbsp;&nbsp;
    <el-link type="success" :underline="false">成功链接</el-link>&nbsp;&nbsp;
    <el-link type="warning" :underline="false">警告链接</el-link>&nbsp;&nbsp;
    <el-link type="danger" :underline="false">危险链接</el-link>&nbsp;&nbsp;
    <el-link type="info" :underline="false">信息链接</el-link
    >&nbsp;&nbsp;<br /><br />

    <el-link icon="el-icon-edit">编辑</el-link>&nbsp;&nbsp;
    <el-link>查看<i class="el-icon-view el-icon--right"></i> </el-link
    >&nbsp;&nbsp;
  </div>
</template>

<script>
export default {
  name: "HelloWorld",
  props: {
    msg: String,
  },
};
</script>

<style scoped>
.el-icon-user {
  font-size: 30px;
  color: green;
}
.el-icon-search {
  font-size: 20px;
  color: black;
}
</style>

本文来自互联网用户投稿,该文观点仅代表作者本人,不代表本站立场。本站仅提供信息存储空间服务,不拥有所有权,不承担相关法律责任。如若转载,请注明出处:http://www.coloradmin.cn/o/1485287.html

如若内容造成侵权/违法违规/事实不符,请联系多彩编程网进行投诉反馈,一经查实,立即删除!

相关文章

LaTeX-设置表格大小

文章目录 LaTeX-设置表格大小1.创建表格2.设置表格的宽度2.1控制表格每一列的宽度2.2控制整个表格的宽度 3.设置表格的外观4.LaTeX绘制三线表 LaTeX-设置表格大小 本文介绍了LaTeX如何设置表格的大小、改变表格的外观以及如何绘制三线表。 1.创建表格 在LaTeX中创建表很耗时…

Springboot+vue的高校教师教研信息填报系统(有报告)。Javaee项目,springboot vue前后端分离项目。

演示视频&#xff1a; Springbootvue的高校教师教研信息填报系统&#xff08;有报告&#xff09;。Javaee项目&#xff0c;springboot vue前后端分离项目。 项目介绍&#xff1a; 采用M&#xff08;model&#xff09;V&#xff08;view&#xff09;C&#xff08;controller&am…

Hololens 2应用开发系列(1)——使用MRTK在Unity中设置混合现实场景并进行程序模拟

Hololens 2应用开发系列&#xff08;1&#xff09;——使用MRTK在Unity中进行程序模拟 一、前言二、创建和设置MR场景三、MRTK输入模拟的开启 一、前言 在前面的文章中&#xff0c;我介绍了Hololens 2开发环境搭建和项目生成部署等相关内容&#xff0c;使我们能生成一个简单Ho…

100个百万阅读公众号爆文案例

100个100万公众号爆文案例 自从公众号流量推送修改之后&#xff0c;原来的私域玩法一去不复返&#xff0c;公域公众号正在崛起 现在公众号的玩法就是找爆款&#xff0c;去对标&#xff0c;去学习&#xff0c;努力使自己的公众号进入流量池&#xff0c;然后吃流量主的收益 这里…

【数据结构和算法】根据前序、中序、后序来确定一颗二叉树

目录 0 引言1 确定二叉树结构的方式1.1 前序和中序1.2 后序和中序1.3 前序和后序&#xff1a;无法确定结构 &#x1f64b;‍♂️ 作者&#xff1a;海码007&#x1f4dc; 专栏&#xff1a;计算机四大基础专栏&#x1f4dc; 其他章节&#xff1a;网络快速入门系列、计网概述、计网…

Redis-基础篇

Redis是一个开源、高性能、内存键值存储数据库&#xff0c;由 Salvatore Sanfilippo&#xff08;网名antirez&#xff09;创建&#xff0c;并在BSD许可下发布。它不仅可以用作缓存系统来加速数据访问&#xff0c;还可以作为持久化的主数据存储系统或消息中间件使用。Redis因其数…

从下一代车规MCU厘清存储器的发展(2)

目录 1.概述 2.MCU大厂的选择 2.1 瑞萨自研STT-MRAM 2.2 ST专注PCM 2.3 英飞凌和台积电联手RRAM 2.4 NXP如何计划eNVM 3.小结 1.概述 上篇文章&#xff0c;我们简述了当前主流的存储器技术&#xff0c;现在我们来讲讲各大MCU大厂的技术选择 2.MCU大厂的选择 瑞萨日…

vue2结合electron开发桌面端应用

一、Electron是什么&#xff1f; Electron是一个使用 JavaScript、HTML 和 CSS 构建桌面应用程序的框架。 嵌入 Chromium 和 Node.js 到 二进制的 Electron 。允许您保持一个 JavaScript 代码代码库并创建可在Windows、macOS和Linux上运行的跨平台应用 。 Electron 经常与 Ch…

文献阅读笔记《Spatial-temporal Forecasting for Regions without Observations》13页

目录 目录 目录 发行刊物 ABSTRACT 1 INTRODUCTION 2 RELATED WORK&#xff08;相关工作 2.1 Spatial-temporal Forecasting&#xff08;时空预测 2.2 Spatial-temporal Forecasting withIncomplete Data&#xff08;不完全数据的时空预测 2.3 Graph Contrastive Lear…

什么是Vue指令?请列举一些常见的Vue指令以及它们的用法

Vue.js 是一款流行的前端框架&#xff0c;它的指令&#xff08;Directives&#xff09;是 Vue.js 提供的一种特殊属性&#xff0c;用于在模板中对 DOM 元素进行直接操作。指令通常是以 v- 开头的特殊属性&#xff0c;用于响应式地将数据绑定到 DOM 元素上。 在 Vue 中&#xf…

VS Code(Visual Studio Code)本地(local)和远程(ssh)Docker Container 下的 Python 开发和调试

VS Code&#xff08;Visual Studio Code&#xff09;本地&#xff08;local&#xff09;和远程&#xff08;ssh&#xff09;Docker Container 下的 Python 开发和调试 1. 目的需求2. VS Code 简介3. 使用实践&#xff1a;一个简单的实例3.1 准备工作3.1.1 远程服务器3.1.2 本地…

测试面试精选题:可用性测试主要测试哪些方面,举例说明

1.界面设计&#xff1a; 评估软件的用户界面设计是否直观、美观、易于理解和操作。 测试用例&#xff1a;打开软件&#xff0c;查看界面布局是否合理&#xff0c;各个功能是否容易找到&#xff0c;是否符合用户习惯。 2.导航和布局&#xff1a; 评估用户在软件中导航和查找…

点云数据结构化与体素化理论学习

一、PCD点云数据存储格式的进一步认识 &#xff08;一&#xff09;PCD点云存储格式相较于其它存储格式&#xff08;如PLY、STL、OBJ、X3D等&#xff09;的优势[1] &#xff08;1&#xff09;具有存储和处理有组织的点云数据集的能力&#xff0c;这对于实时应用和增强现实及机器…

【C++】string 类 ( 上)

标准库中的string类 注意&#xff1a; 1. string是表示字符串的字符串类 2. 该类的接口与常规容器的接口基本相同&#xff0c;再添加了一些专门用来操作string的常规操作。 比特就业课 3. string在底层实际是&#xff1a;basic_string模板类的别名&#xff0c;typedef basi…

Python3零基础教程之数学运算专题初阶

大家好,我是千与编程,在上一节课程我们讲解了Python3基础课程中的变量与数据专题项目,本章节中涉及的Python3编程语言中的基础的四则运算、赋值运算符号,赋值运算符号,比较运算符号,位运算符号的计算方法。 这一章的内容算是比较基础的部分,最后需要学会使用即可。以下是…

飞天使-学以致用-devops知识点2-安装sonarqube

文章目录 安装sonarqube查看暴露出去的端口 生成服务token创建webhook服务创建项目 安装sonarqube apiVersion: apps/v1 kind: Deployment metadata:name: postgres-sonarnamespace: kube-devops spec:replicas: 1selector:matchLabels:app: postgres-sonartemplate:metadata:…

物联网与智慧城市:科技驱动下的城市智能化升级之路

一、引言 随着科技的不断进步和城市化进程的加速&#xff0c;物联网与智慧城市的结合已经成为推动城市智能化升级的关键力量。物联网技术以其强大的连接和数据处理能力&#xff0c;为智慧城市的建设提供了无限可能。本文旨在探讨物联网如何助力智慧城市的构建&#xff0c;以及…

实例驱动计算机网络

文章目录 计算机网络的层次结构应用层DNSHTTP协议HTTP请求响应过程 运输层TCP协议TCP协议面向连接实现TCP的三次握手连接TCP的四次挥手断开连接 TCP协议可靠性实现TCP的流量控制TCP的拥塞控制TCP的重传机制 UDP协议 网际层IP协议&#xff08;主机与主机&#xff09;IP地址的分类…

朱维群将出席用碳不排碳碳中和顶层科技路线设计开发

演讲嘉宾&#xff1a;朱维群 演讲题目&#xff1a;“用碳不排碳”碳中和顶层科技路线设计开发 简介 姓名&#xff1a;朱维群 性别&#xff1a;男 出生日期&#xff1a;1961-09-09 职称&#xff1a;教授 1998年毕业于大连理工大学精细化工国家重点实验室精细化工专业&…

【ArcGIS Pro二次开发】(83):ProWindow和WPF的一些技巧

在ArcGIS Pro二次开发中&#xff0c;SDK提供了一种工具界面【ArcGIS Pro ProWindow】。 关于ProWindow的用法&#xff0c;之前写过一篇基础的教程&#xff1a; 【ArcGIS Pro二次开发】(13)&#xff1a;ProWindow的用法_arcgispro二次开发教程-CSDN博客 主要是对几个常用控件…