Vuejs toggle class in v-for
问题 I'm making a list of items with v-for loop. I have some API data from server. items: [ { foo: 'something', number: 1 }, { foo: 'anything', number: 2 } ] and my template is: <div v-for(item,index) in items @click=toggleActive> {{ item.foo }} {{ item.number }} </div> JS: methods: { toggleActive() { // } } How can i toggle active class with :class={active : something} ? P.S I don't have boolean value in items 回答1: You can try to implement something like: <div v-for="(item, index) in items" v