Answers for "vuejs add class if"

14

vue conditional class

<div :class="{ 'prop-name': boolVar }"></div>
Posted by: Guest on March-15-2020
6

vue inline style bind

<div v-bind:style="{ color: activeColor, fontSize: fontSize + 'px' }"></div>
Posted by: Guest on May-07-2020
2

vue if echo class

<div class="defaultclass" :class="condition?' conditionalclasstoappend':''"></div>
Posted by: Guest on February-21-2020
0

vue div class v-if addclass

new Vue({
  el: "#app",
  data: {
    items: [
      { label: 'foo', status: true },
      { label: 'bar', status: false }
    ]
  }
})
.text-red {
  color: red;
}
<script src="https://cdn.jsdelivr.net/npm/vue"></script>

<div id="app">
  <p v-for="item in items" v-bind:class="{ 'text-red': item.status }">
    {{item.label}}
  </p>
</div>
Posted by: Guest on September-10-2021

Browse Popular Code Answers by Language