1<template>
2 <div>
3 <div
4 class="staticClass"
5 v-bind:class="{ active: isActive, 'text-danger': hasError }"
6 ></div>
7 <!-- OR -->
8 <div
9 v-bind:class="[isActive ? activeClass : '', errorClass]"
10 ></div>
11 </div>
12</template>
13
14<script>
15 export default {
16 data() {
17 isActive: true,
18 hasError: false,
19 activeClass: 'active',
20 errorClass: 'text-danger',
21 }
22 }
23</script>
1<button @click="variable = !variable">
2 Toggle Value
3</button>
4
5<script>
6export default {
7 data () {
8 return {
9 variable: false
10 }
11 }
12}
13</script>