<template>
  //:class="{样式名:布尔值}"
  <div :class="{selected:flag}" @click="clickBtn">点击改变颜色</div>
</template>
export default{ 
data(){
      return{
        flag :false
      }
    },
methods:{
 clickBtn(){
       this.flag = !this.flag
  }
   }
}
<style scoped>
.selected{
    color: red
}
<style>

相关文章:

  • 2021-09-06
  • 2022-12-23
  • 2022-12-23
  • 2021-11-29
  • 2022-02-20
  • 2021-10-14
  • 2021-12-06
猜你喜欢
  • 2022-12-23
  • 2022-12-23
  • 2022-12-23
  • 2021-09-08
  • 2022-01-25
  • 2022-12-23
  • 2022-12-23
相关资源
相似解决方案