Answer the question
In order to leave comments, you need to log in
How to replace object name in vue.js loop?
The question was formulated rather clumsily, but the essence is as follows.
When you click on the li tag, you need to replace blockItems.items1 with blockItems.items2, and when you click again, replace blockItems.items2 with blockItems.items1
<ul class='items'>
<li class='item' @click='replacItems' v-for='item in blockItems.items1'>
<div class='item__title'>{{ item.title }}</div>
</li>
</ul>
blockItems: {
items1: [
{title: 'Загловок 1'},
{title: 'Заголовк 2'},
],
items2: [
{title: 'Загловок 3'},
{title: 'Заголовк 4'},
]
}
replacItems() {
this.blockItems.items1 = this.blockItems.items2;
}
Answer the question
In order to leave comments, you need to log in
Didn't find what you were looking for?
Ask your questionAsk a Question
731 491 924 answers to any question