0๐
If you work with Vue.js, iโd rather go for the conditional rendering.
Take a look here: https://v2.vuejs.org/v2/guide/conditional.html.
Thats something like this:
<div v-if="temp > 0 && temp <= 3" class="winter"></div>
<div v-else-if="temp > 3 and <= 10" class="warm"></div>
<div v-else class="hot"></div>
0๐
You can use :class
to bind the styles dynamically.
Working Demo :
new Vue({
el: '#app',
data: {
temp: 10
}
});
.winter {
background-color: green;
}
.spring {
background-color: yellow;
}
.warm {
background-color: red;
}
<script src="https://cdnjs.cloudflare.com/ajax/libs/vue/2.5.17/vue.js"></script>
<div id="app">
<div :class="{
winter: `${temp}` < 0,
warm: `${temp}` > 16,
spring: (`${temp}` > 5) && (`${temp}` < 15)
}">
Weather
</div>
</div>
- [Vuejs]-Vue Vuetify center horizontally and vertically
- [Vuejs]-Vue js not rendering VdtnetTable. What might be the issue
Source:stackexchange.com