[Vuejs]-Filter data from nested array in vue.js

4👍

Currently you are filtering faq so for each item you are going to take either all its content or none.

You could do something like this:

function filterfaq () {
  const search = this.searchValue.toLowerCase().trim();
  if (!search) return this.faq;
  return this.faq.map(item => {
    return {
      ...item,
      content: item.content.filter(question => {
        return question.qus.toLowerCase().includes(search);
      }),
    }
  });
}

Leave a comment