Answers for "vue class binding ternary"

2

bind style with condition in vue

v-bind:style= "[condition ? {styleA} : {styleB}]"
Posted by: Guest on July-20-2020
4

bind style with condition in vue

<figure :style="[item.main_featured ? {'background': 'url(' + item.main_featured + ') center no-repeat'} : {'background': '#FFF'}]">
Posted by: Guest on July-20-2020
-1

vue class binding if else

vue class binding if else
<div :class="{ 'prop-name': boolVar }"></div>
:class="darkMode ? 'dark-theme' : 'light-theme'"
If darkMode is true, we apply dark-theme as our class name. 
	Otherwise we choose light-theme.
Posted by: Guest on December-04-2020

Browse Popular Code Answers by Language