S
S
SPART4K632021-06-01 15:50:31
Vue.js
SPART4K63, 2021-06-01 15:50:31

Can I swap data from v-for in a branch?

Good afternoon, I have such a design.

<BaseCardDefault 

        class="timing-card-list__item"
        v-for="(item, key, index) of sortTiming"
        >

Can I change 'sortTiming' depending on what is allowed in data() sortOff: false.
Conditionally, when sortOff: false , I will take data from sortTiming, and when true . from sortHouse ?

Answer the question

In order to leave comments, you need to log in

1 answer(s)
0
0xD34F, 2021-06-01
@SPART4K63

v-for="n in (condition ? items1 : items2)"
You can wrap it in a computed property:

computed: {
  items() {
    return condition ? this.items1 : this.items2;
  },
},

v-for="n in items"

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question