I'm trying to use the filter with vue, but I'm having difficulty.
Code:
list() {
var self=this
const list = this.programas;
if (_.isEmpty(this.filter)) {
return list;
}
return list.filter(function(item) {
return item.funcao.indexOf(self.filter) > -1
})
}
It works perfectly when I pass a string
to the filter, however I need the filter to be an array, how do I?
This is my object:
dsgpProgramas:[
{
'categoria': 'Entidades',
'funcao': 'Cadastro',
},
{
'categoria': 'Entidades',
'funcao': 'Operacao',
},
{
'categoria': 'Entidades',
'funcao': 'Consulta',
},
{
'categoria': 'Entidades',
'funcao': 'Parametros',
},
]
this is my filter
filtro = ['cadastro','consulta']
only works when my filter looks like this:
filtro= ['cadastro']
That is, it only works when I filter the array with a single-parameter filter, but in this example I need to bring the array records where the function is equal to the register or query, not just one or the other. >