Linked Questions

Popular Questions

find arrays that contain a string

Asked by At

I have a vuejs project and i want to implement a search component with a list component i got what i need from search component and passed it to list component and in it i have a computed function for filtering its list items

I tried this but does not work as i intended

 filteredItems() {
      return this.items.filter(item => {
        if (this.search != "") return item.includes(this.search);
        else return true;
      });
    }

in this code if i have such array as list items

items:[
   ['abc','def','ghi'],
   ['ajk,'lmn','opq']
]

and if i pass 'a' to my computed function i want both of those arrays but get nothing and i have to pass specifically 'abc' to only get first array and that is not how searching works.

can somebody help me to fix this?

Related Questions