L
L
litash2018-07-26 19:16:57
Vue.js
litash, 2018-07-26 19:16:57

How to access a nested array and display it in the filter list?

I don’t know how to access a nested array in the items array in computed find(), instead of hello and world, you need to display those in items ->> props.
https://codepen.io/litash/pen/OwjGWe

Answer the question

In order to leave comments, you need to log in

1 answer(s)
0
0xD34F, 2018-07-26
@litash

computed: {
  foundItems() {
    return []
      .concat(...this.items.map(n => n.props || []))
      .filter(n => n.name.includes(this.search));
  },
},

<li v-for="item in foundItems">
  {{ item.name }}
</li>

https://jsfiddle.net/8qyrtsac/

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question