效果图:
1. 我们可以给要循环的盒子动态绑定class名 并且传入一个数组
<div class="AllPeople" v-for="(item , index) in rankingData" :key="index" :class="sstt[index]">
<div class="inner">
<span class="innerContent">TOP1告警区域 {{item.area}}</span>
</div>
</div>
后台请求的数据:
ranking(){
this.$http.get('/api/warning/getTopThree').then((res)=>{
if(res.data.status === 200){
console.log(res.data.data)
this.rankingData = res.data.data
}
})
},
2. 在data中定义这个数组
sstt: [
"high",
"Medium",
"low"
],
3. 在style中分别设置样式就可以了
.Medium {
background-color: #75b9e6;
}
.low {
background-color: #71d398;
}