数组语法
<div v-bind:class="[activeClass, errorClass]"></div>
data: {
activeClass: 'active',
errorClass: 'text-danger'
}
对象语法
<div
class="static"
v-bind:class="{ active: isActive, 'text-danger': hasError }"
></div>
data: {
isActive: true,
hasError: false
}
对象与数组混用
<div v-bind:class="[activeClass, {active: isActive}]></div>
data: {
activeClass: 'active',
isActive: true
}