<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>
Logo

前往低代码交流专区

更多推荐