vue动态添加类名

vue动态添加类名

1. 三元运算表达式

:class="show==true? 'style1':'style2'"

2.多个类名 使用Boolean值来判断类名是否生效

:class="{votes:true,votes2:2>1}"

3. 多个类名,且有固定类名

:class="[owl,{ password: flag }]"
export default {
  data() {
    return {
      owl: 'owl',
      flag: '',
      	}
   }
 }

参考:https://blog.csdn.net/qq_45079530/article/details/122260616 他的csdn

posted @ 2022-05-16 10:51  张尊娟  阅读(425)  评论(0编辑  收藏  举报