一.
new Vue({
el: '#app',
data: {
isActive: true
}
})
二.
v-bind:class="{ active: isActive, 'text-danger': hasError }">
new Vue({
el: '#app',
data: {
isActive: true,
hasError: true
}
})
三.
.active {
width: 100px;
height: 100px;
background: green;
}
.text-danger {
background: red;
}
new Vue({
el: '#app',
data: {
classObject: {
active: true,
'text-danger': true
}
}
})
四.
.active {
width: 100px;
height: 100px;
background: green