Answer the question
In order to leave comments, you need to log in
Dynamic class change in vue component?
Is it possible to dynamically change a class in a vue component? There is vue:
new Vue({
el:'.container',
data:{
areas: new Array(24),
}
})
Vue.component('photos',{
template:'#template-areas',
props:['index'],
})
v-for="(item, index) in areas"
:key="index"
:index="index+1"
template id="template-areas"
div class=area{{index}}
Answer the question
In order to leave comments, you need to log in
Documentation: https://ru.vuejs.org/v2/guide/class-and-style.html
Just addv-bind:class="'area' + index"
Didn't find what you were looking for?
Ask your questionAsk a Question
731 491 924 answers to any question