<div v-bind:class="classObject"></div>

js部分

export default{
  data () {
    return {
        classObject:[{
        'classA':true,'classB':false,'classC':false,'classD':false,'classE':false
      }],
}
}

css部分

.classA{
  background:url("../assets/img1/alert-info-normal.gif") 0 0 no-repeat scroll transparent;
}
.classB{
  background:url("../assets/img1/alert-info-first.gif") 0 0 no-repeat scroll transparent;
}
.classC {
  background:url("../assets/img1/alert-info-second.gif") 0 0 no-repeat scroll transparent;
}
.classD {
  background:url("../assets/img1/alert-info-third.gif") 0 0 no-repeat scroll transparent;
}
.classE {
  background:url("../assets/img1/alert-info-fourth.gif") 0 0 no-repeat scroll transparent;
}

js方法中

if (resData.level ===  0) {
   _this.classObject[0].classA=true,_this.classObject[0].classB=false,
   _this.classObject[0].classC=false,_this.classObject[0].classD=false,
   _this.classObject[0].classE=false
}else if (resData.level ===  0) {
   _this.classObject[0].classA=false, _this.classObject[0].classB=true, 
   _this.classObject[0].classC=false, _this.classObject[0].classD=false, 
   _this.classObject[0].classE=false,
}else ...

 

Logo

前往低代码交流专区

更多推荐