Answers for "vue css dinamic class if else and other classes"

1

conditional class vue

<template>
  <span
    class="description"
    :class="darkMode ? 'dark-theme' : 'light-theme'"
  >
    This is how you add dynamic classes in Vue.
  </span>
</template>
Posted by: Guest on April-18-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