vue中动态绑定class

时间:2023-03-08 22:22:41

我用的element-ui

vue中动态绑定classprimary默认是这个颜色,ui设计的是这个颜色vue中动态绑定class所以我们先要重写

.el-button--primary的样式

vue中动态绑定class

因为默认是没有勾选的所有事灰色所以下面重写样式为灰色

.el-button--primary {

  color: #fff;
background-color: gainsboro;
border-color: gainsboro;
}
有一点我想不通,就是通过是否被选中来改变这个.el-button--primary或者说动态绑定这个类

vue中动态绑定class

vue中动态绑定class

vue中动态绑定class

通过计算属性来实现是否能点击


因为之前我都是写在,所以我没想通
<style scoped lang="less">

.el-button--primary {

  color: #fff;
background-color: gainsboro;
border-color: gainsboro;
}
</style>

现在想通了 另外写一个类来实现动态绑定

vue中动态绑定class


 其实就是重写类的时候,另外起一个style 然后就是动态绑定