element el-button按钮,根据不同数据改变按钮type类型 调整按钮颜色
element
A Vue.js 2.0 UI Toolkit for Web
项目地址:https://gitcode.com/gh_mirrors/eleme/element
![](https://devpress.csdnimg.cn/6deffb34f7114cc1a2e1e686a67e0027.png)
·
需求:状态弹框中每个按钮颜色都不同,因为使用的是统一的弹框组件 ,所以就想了一下,element ui 按钮的type类型 是否可以根据不同的条件进行动态取值讷,然后再调整颜色讷?
代码实现:
<el-button size="mini" :type="buttonType(title)" @click="clickOk()">
Confirm
</el-button>
methods:
buttonType(val) {
if (val == "Success") {
return "primary";
} else if (val == "Eror") {
return "danger";
} else {
return "info";
}
},
css样式:
<style lang="scss" >
.el-button--primary {
background: #409e2a;
border-color: #409e2a;
}
.el-button--info {
background-color: #ebd70a;
border-color: #ebd70a;
}
}
</style>
![]( https://profile-avatar.csdnimg.cn/default.jpg)
![](https://devpress.csdnimg.cn/7174e1ca86c447029bb12f9ec0bd281c.png)
![](https://devpress.csdnimg.cn/096f7827187446559bd7b6030eb5db38.png)
![](https://devpress.csdnimg.cn/6deffb34f7114cc1a2e1e686a67e0027.png)
A Vue.js 2.0 UI Toolkit for Web
最近提交(Master分支:6 个月前 )
c345bb45
10 个月前
a07f3a59
* Update transition.md
* Update table.md
* Update transition.md
* Update table.md
* Update transition.md
* Update table.md
* Update table.md
* Update transition.md
* Update popover.md 10 个月前
更多推荐
所有评论(0)