vue动态切换class类

论坛 期权论坛 编程之家     
选择匿名的用户   2021-6-2 20:14   2513   0
 <div id="wrap" class="box">
    <div  :class="{ red:isTrue}" @click="tago" class="blue">动态切换class类</div>
  </div>
</template>

<script>
    export default {
        name: "demo",
        data(){
          return{
            isTrue:true
          }

      },
      methods:{
        tago(){
          this.isTrue = !this.isTrue;
          console.log(123)
        }
      }

    }
</script>

<style scoped>
  .blue{
    width: 100px;
    height: 100px;
    background: blue;
  }
  .red{
    width: 200px;
    height: 200px;
    background: red;
  }
</style>
分享到 :
0 人收藏
您需要登录后才可以回帖 登录 | 立即注册

本版积分规则

积分:3875789
帖子:775174
精华:0
期权论坛 期权论坛
发布
内容

下载期权论坛手机APP