Element Plus中button按钮相关大全

一、基本用法

使用 typeplainround 和 circle 来定义按钮的样式。

样式代码如下:

<template><div class="mb-4"><el-button>Default</el-button><el-button type="primary">Primary</el-button><el-button type="success">Success</el-button><el-button type="info">Info</el-button><el-button type="warning">Warning</el-button><el-button type="danger">Danger</el-button></div><div class="mb-4"><el-button plain>Plain</el-button><el-button type="primary" plain>Primary</el-button><el-button type="success" plain>Success</el-button><el-button type="info" plain>Info</el-button><el-button type="warning" plain>Warning</el-button><el-button type="danger" plain>Danger</el-button></div><div class="mb-4"><el-button round>Round</el-button><el-button type="primary" round>Primary</el-button><el-button type="success" round>Success</el-button><el-button type="info" round>Info</el-button><el-button type="warning" round>Warning</el-button><el-button type="danger" round>Danger</el-button></div><div><el-button :icon="Search" circle /><el-button type="primary" :icon="Edit" circle /><el-button type="success" :icon="Check" circle /><el-button type="info" :icon="Message" circle /><el-button type="warning" :icon="Star" circle /><el-button type="danger" :icon="Delete" circle /></div>
</template><script lang="ts" setup>
import {Check,Delete,Edit,Message,Search,Star,
} from '@element-plus/icons-vue'
</script>

 二、禁用状态

可以使用 disabled 属性来定义按钮是否被禁用。

使用 disabled 属性来控制按钮是否为禁用状态。 该属性接受一个 Boolean 类型的值。

样式代码如下: 

<template><div class="mb-4"><el-button disabled>Default</el-button><el-button type="primary" disabled>Primary</el-button><el-button type="success" disabled>Success</el-button><el-button type="info" disabled>Info</el-button><el-button type="warning" disabled>Warning</el-button><el-button type="danger" disabled>Danger</el-button></div><div><el-button plain disabled>Plain</el-button><el-button type="primary" plain disabled>Primary</el-button><el-button type="success" plain disabled>Success</el-button><el-button type="info" plain disabled>Info</el-button><el-button type="warning" plain disabled>Warning</el-button><el-button type="danger" plain disabled>Danger</el-button></div>
</template>

 三、链接按钮

新的 API link 于 2.2.1 版本时添加,你可以使用 type API 设置链接按钮的主题样式

样式代码如下: 

<template><p>Basic link button</p><div class="mb-4"><el-buttonv-for="button in buttons":key="button.text":type="button.type"link>{{ button.text }}</el-button></div><p>Disabled link button</p><div><el-buttonv-for="button in buttons":key="button.text":type="button.type"linkdisabled>{{ button.text }}</el-button></div>
</template><script setup lang="ts">
const buttons = [{ type: '', text: 'plain' },{ type: 'primary', text: 'primary' },{ type: 'success', text: 'success' },{ type: 'info', text: 'info' },{ type: 'warning', text: 'warning' },{ type: 'danger', text: 'danger' },
] as const
</script>

 四、文字按钮

文字按钮在现在有了全新的设计样式。 2.2.0 如果您想要使用老版样式的按钮,可以考虑使用 Link 组件。

API也已更新,由于 type 属性会同时控制按钮的样式, 因此我们通过一个新的 API text: boolean 来控制文字按钮。

五、图标按钮

使用图标为按钮添加更多的含义。 你也可以单独使用图标不添加文字来节省显示区域占用。

使用 icon 属性来为按钮添加图标。 您可以在我们的 Icon 组件中找到所需图标。 通过向右方添加<i>标签来添加图标, 你也可以使用自定义图标。

样式代码如下: 

<template><div><el-button type="primary" :icon="Edit" /><el-button type="primary" :icon="Share" /><el-button type="primary" :icon="Delete" /><el-button type="primary" :icon="Search">Search</el-button><el-button type="primary">Upload<el-icon class="el-icon--right"><Upload /></el-icon></el-button></div>
</template>
<script setup lang="ts">
import { Delete, Edit, Search, Share, Upload } from '@element-plus/icons-vue'
</script>

六、按钮组

以按钮组的方式出现,常用于多项类似操作。

使用 <el-button-group> 对多个按钮分组。

样式代码如下: 

<template><el-button-group><el-button type="primary" :icon="ArrowLeft">Previous Page</el-button><el-button type="primary">Next Page<el-icon class="el-icon--right"><ArrowRight /></el-icon></el-button></el-button-group><el-button-group class="ml-4"><el-button type="primary" :icon="Edit" /><el-button type="primary" :icon="Share" /><el-button type="primary" :icon="Delete" /></el-button-group>
</template><script setup lang="ts">
import {ArrowLeft,ArrowRight,Delete,Edit,Share,
} from '@element-plus/icons-vue'
</script>

七、加载状态按钮

点击按钮来加载数据,并向用户反馈加载状态。

通过设置 loading 属性为 true 来显示加载中状态。

八、调整尺寸

除了默认的大小,按钮组件还提供了几种额外的尺寸可供选择,以便适配不同的场景。

使用 size 属性额外配置尺寸,可使用 largesmall两种值。

样式代码如下: 

<template><div class="flex flex-wrap items-center mb-4"><el-button size="large">Large</el-button><el-button>Default</el-button><el-button size="small">Small</el-button><el-button size="large" :icon="Search">Search</el-button><el-button :icon="Search">Search</el-button><el-button size="small" :icon="Search">Search</el-button></div><div class="flex flex-wrap items-center mb-4"><el-button size="large" round>Large</el-button><el-button round>Default</el-button><el-button size="small" round>Small</el-button><el-button size="large" :icon="Search" round>Search</el-button><el-button :icon="Search" round>Search</el-button><el-button size="small" :icon="Search" round>Search</el-button></div><div class="flex flex-wrap items-center"><el-button :icon="Search" size="large" circle /><el-button :icon="Search" circle /><el-button :icon="Search" size="small" circle /></div>
</template><script setup lang="ts">
import { Search } from '@element-plus/icons-vue'
</script>

九、Tag

可以自定义元素标签。例如,按钮,div,路由链接,nuxt链接。

十、自定义颜色

可以自定义按钮的颜色。

我们将自动计算按钮处于 hover 和 active 状态时的颜色。

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

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

相关文章

C语言常见字符串函数模拟实现一

strlen模拟实现 重点&#xff1a;1.字符串已经\0作为结束标志&#xff0c;strlen返回的是字符串\0前面出现的字符个数&#xff08;不包含\0&#xff09; 2.参数指向的字符串必须要以\0结束。 3.注意函数的返回值是size_t&#xff0c;是无符号的&#xff0c;加减是无法对比的。…

卡西欧相机SD卡格式化后数据恢复指南

在数字摄影时代&#xff0c;卡西欧相机以其卓越的性能和便携性成为了众多摄影爱好者的首选。然而&#xff0c;随着拍摄量的增加&#xff0c;SD卡中的数据管理变得尤为重要。不幸的是&#xff0c;有时我们可能会因为操作失误或系统故障而将SD卡格式化&#xff0c;导致珍贵的照片…

数据类型转换中存在的问题分析

隐式类型转换&#xff08;implicit type conversion&#xff09; 隐式类型转换&#xff08;implicit type conversion&#xff09;包括整型提升&#xff08;integer promotion&#xff09;和标准算数转换&#xff08;usual arithmetic conversions&#xff09; 遵循较大范围优…

堡垒机(Bastion Host)概述

Bastion Host 堡垒机 一、什么是堡垒机&#xff1f; A bastion host is a computer specially designed to mitigate cyberattacks and manage access rights to an internal network. 堡垒机Bastion Host是一种专门设计用于缓解网络攻击并管理内部网络访问权限的计算机。 在…

肖扬新书《微权力下的项目管理》读书笔记2

一个核心思想&#xff1a;“借力” 合格的项目经理是不热衷于培养人的。项目经理的工作场景和职能经理的工作场景往往有很 大不同。职能经理的工作方式通常适用于常态化工作&#xff0c;要有足够的时间去培养人&#xff0c;先把人培 养起来&#xff0c;然后再干事&#xff0c;可…

加油卡APP定制搭建,让加油更便捷!

在汽车时代中&#xff0c;汽车的数量不断增加&#xff0c;加油已经成为了大众生活中不可缺少的一部分。同时&#xff0c;加油卡的出现也为大众的汽车加油提供了更多的优惠方式&#xff0c;为大众节省经济开支&#xff0c;为车主带来便利&#xff1b;同时加油卡的发展也提高了加…

2024年华为杯研赛(E题)数学建模竞赛解题思路|完整代码论文集合

我是Tina表姐&#xff0c;毕业于中国人民大学&#xff0c;对数学建模的热爱让我在这一领域深耕多年。我的建模思路已经帮助了百余位学习者和参赛者在数学建模的道路上取得了显著的进步和成就。现在&#xff0c;我将这份宝贵的经验和知识凝练成一份全面的解题思路与代码论文集合…

如何远程访问局域网内的电脑?局域网内远程桌面怎么实现?揭秘4种干货技巧

想象一下&#xff0c;你正在办公室A&#xff0c;而你想访问办公室B里的某台电脑&#xff0c;却不想起身到另一楼层甚至是另一个房间。 如何不动身就能控制局域网内的另一台电脑呢&#xff1f; 这并不是科幻&#xff0c;而是完全可以通过远程桌面技术来实现。 今天&#xff0…

学习Java(一)类和对象

package demo.ceshi;public class Puppy {private int age;private String name;//构造器public Puppy( String name){this.name name;System.out.println("公主的名字叫&#xff1a;"name);}//设置age的值public void setAge(int age){this.age age;System.out.pr…

智慧仓储-AI销量预测

1、预测系统技术选型 基础层&#xff1a; Hbase、ClickHouse、Hdfs 用来做数据存储 框架层&#xff1a; 以 Spark RDD、Spark SQL、Hive 为主&#xff0c; MapReduce 程序占一小部分&#xff0c;是原先遗留下来的&#xff0c;目前正逐步替换成 Spark RDD。 选择 Spark 除了对…

rsyslogd 内存占用很高解决方案

在Kubernetes&#xff08;K8S&#xff09;集群中&#xff0c;监控日志是非常重要的&#xff0c;而rsyslogd是Linux系统中用于处理系统和应用程序日志的守护进程。有时候rsyslogd可能会占用较高的内存&#xff0c;这时候我们就需要对其进行优化和调整。 阿里云虚拟服务器&…

创客中国AIGC专题赛冠军天鹜科技:AI蛋白质设计引领者

“落霞与孤鹜齐飞,秋水共长天一色——这句出自《滕王阁序》的诗句,是我作为江西人熟记于心的佳句。它描绘的天地壮丽景色常浮现于我的脑海,正是这种豁达与壮观,启发我们将公司命名为‘天鹜科技’,我们希望将源自自然的蛋白质与现代科技的创新精神相结合,打造蛋白质设计与应用的…

16_Python的迭代器

在Python中&#xff0c;迭代是一个非常重要的概念。迭代通常指的是按照某种顺序逐个访问容器中的元素的行为。如使用for循环遍历取值的过程。 可迭代对象&#xff08;Iterable&#xff09; 可迭代对象是任何可以返回一个迭代器的对象。简单来说&#xff0c;它是可以逐一返回其…

机器学习模型中特征贡献度分析:预测贡献与错误贡献

在机器学习领域&#xff0c;特征重要性分析是一种广泛应用的模型解释工具。但是特征重要性并不等同于特征质量。本文将探讨特征重要性与特征有效性之间的关系&#xff0c;并引入两个关键概念&#xff1a;预测贡献度和错误贡献度。 核心概念 预测贡献度&#xff1a;衡量特征在…

【C++】—— stack queue deque

【C】—— stack & queue & deque 1 stack 与 queue 的函数接口2 适配器2.1 发现问题2.2 什么是适配器 3 stack 与 queue的模拟实现3.1 栈的基础框架3.2 栈的模拟实现3.3 队列的模拟实现 4 模板的按需实例化5 deque 的简单介绍5.1 vector 与list对比5.1.1 vector5.1.2 …

C++函数重载完成日期类相关计算

本文内容如下&#xff1a; 1.创建类以及函数的声明2.日期加减天数1.月份天数2.函数实现 3.日期比较大小4.日期减日期1.日期的前置和后置加加2.日期减日期的实现 5.内置类型的cout和cin本文代码如下&#xff1a; 要完成日期类的相关计算要创建自定义的类型&#xff0c;然后用函数…

获取IPV6地址的参考网站|nginx解析IPV6|linux服务器获取IPV6的方法

获取IPV6地址的参考网站 网址1 https://v6.ident.me/ 网址2 https://ifconfig.co/ 网址3 https://ifconfig.me/ IPV6检测站点推荐 网址1 http://ipv6-test.ch/ linux服务器获取IPV6的方法 以centos7为例 curl -6 ifconfig.mecurl -6 https://v6.ident.mecurl -6 https:…

python安装-升级

这里写自定义目录标题 欢迎使用Markdown编辑器 欢迎使用Markdown编辑器 运行python 或pycharm时报错 [notice] A new release of pip is available: 23.1.2 -> 24.2 [notice] To update, run: python.exe -m pip install --upgrade pipCMD 进入 DOS C:\Users\wang>pyt…

解密MQ消息积压:让你系统瞬间卡死的幕后黑手

文章目录 什么是MQ消息积压&#xff1f;消息积压的常见原因案例分析&#xff1a;如何处理消息积压&#xff1f;场景1&#xff1a;消费者处理速度过慢场景2&#xff1a;消息生产速度过快 如何预防消息积压&#xff1f;1. **监控与告警**2. **动态扩容**3. **限流与降级**4. **合…

插入与冒泡排序(C++)

\一、插入排序 1 简介 插入排序&#xff0c;也称为直接插入排序&#xff0c;其排序思想和我们平时打扑克牌时排序类似。 2 算法步骤 将第一个元素看作已排序序列&#xff0c;第二个到最后一个看作未排序序列。 第二个元素&#xff0c;与之前已排序号的序列进行对比&#x…