2

I'm trying to create divs with specific values received from a getter in ts file. I'm using Vue.js

filters: filters, 
    // e.g. [
    //        0: {filter: "filter1"}
    //        1: {filter: "filter2"}
    //        2: {filter: "filter3"}
    //        3: {filter: "filter4"}
    //      ]

values: values,
    // e.g. [
    //        0: {value: "11111"}
    //        1: {value: "22222"}
    //        2: {value: "33333"}
    //        3: {value: "44444"}
    //      ]

What I want to achieve is to display 4 divs and in each of them

<div class="filters-value-wraper">
   <div v-for="(item, index) in filtersComponents()" class="filters-value">
      <div class="filter"> {{ item.filters.filter }}</div>
      <div class="values">{{ item.values.value }}</div>
   </div>
</div>

All I can do is to display the whole filters/values array but I don't know how to "throw" another value from the array for each subsequent div. I mean for the first value[0] and filter[0] for the second value[1] and filter[1] etc.

1
  • 1
    Can you show filtersComponents()? This v-for doesn't look right even if the index is fixed Commented Nov 22, 2020 at 15:32

1 Answer 1

2

If I understand what you're asking, it should be:

<div class="filter"> {{ item.filters[index].filter }} </div>
<div class="values"> {{ item.values[index].value }} </div>

You use the index to access the array by index

Sign up to request clarification or add additional context in comments.

1 Comment

It works! Can't believe that solution i so simple and I din't figure it out. Thank you very much for your time :)

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.