I create a filter function and I want to show the result. Here's the code
data() {
return {
questionList: faqData.flatMap(q => q.questions)
}
},
computed: {
search() {
return this.$store.state.search
},
filter: function() {
this.questionList.filter((x) => {
return x.question.match(this.search);
})
}
}
There's no problem with the questionList variable and the search() function. And I think the problem is in the filter() function. Anyway, here's my questionList
[{id: 1, question: 'blabla', answer: 'blabalbla'}, {id: 2, question: 'blabla', answer: 'blabalbla'}, {id: 3, question: 'blabla', answer: 'blabalbla'} ]
the filter function shows an empty array. Can anyone tell me where did I do it wrong? Thanks!
this.resultandthis.filterare completely the same.