vue的class对象绑定 发表于 2018-05-29 | 分类于 vue 本节课程:v-bind:class v-bind:class123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051下面我们对html进行了class的绑定<!DOCTYPE html><html lang="en"><head> <meta charset="UTF-8"> <title>vueDemo</title> <script src="https://cdn.jsdelivr.net/npm/vue"></script></head><style> .active { color: red; } .big { font-weight: bolder; font-size: 64px; }</style><body> <div id="myApp"> <div v-bind:class="myClass">文本</div> <button @click="btnClick">点击改变</button> </div></body></html><script > var myApp = new Vue ({ el: "#myApp", data: { myClass: { active:true, big:true } }, methods: { btnClick: function() { this.myClass.active = !this.myClass.active; this.myClass.big = !this.myClass.big; } } })</script> -------------本文结束感谢您的阅读-------------