vue dynamically adds class and more than three conditions are used as judgment methods

  • 2021-09-11 19:31:14
  • OfStack

If status is 1, the style is redRoom

If status is 2, the style is greenRoom1

If status is other, the style is greenRoom2

:class="{'redRoom': Number(items.status) === 1, 'greenRoom1': Number(items.status) === 2, greenRoom2: Number(items.status) > 2}"

Supplementary knowledge: vue judges and displays class according to variable values

I won't talk too much, let's just look at the code ~

< div :class="['bottom-btn',{'face-btn':type=='face'}]" >

< /div >


Related articles: