[Vuejs]-Filtering multiple fields in object at once Vue.js

1👍

you want theuser[shownFields[i]] not theuser.shownFields[i] because theuser does not have a property called shownFields

You also what to change i <= shownFields.length to i < shownFields.length – because the length of an array is one greater than the highest index

return this.items.filter(function(theuser) {
    for(var i = 0; i < shownFields.length; i++) { // change here
       if(theuser[shownFields[i]].toLowerCase().includes(searchinput.toLowerCase())) { // change here
           return theuser[shownFields[i]].toLowerCase().includes(searchinput.toLowerCase()); // change here
       }
    }
});

Leave a comment