0
I’m trying to use the filter with Vue, but I’m having trouble.
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 step one string
for the filter, but I need the filter to be an array, as I do?
This is my object:
dsgpProgramas:[
{
'categoria': 'Entidades',
'funcao': 'Cadastro',
},
{
'categoria': 'Entidades',
'funcao': 'Operacao',
},
{
'categoria': 'Entidades',
'funcao': 'Consulta',
},
{
'categoria': 'Entidades',
'funcao': 'Parametros',
},
]
that’s my filter
filtro = ['cadastro','consulta']
only works when my filter is like this:
filtro= ['cadastro']
i.e., it only works when you filter the array through a filter with a single parameter, but in this precise example bring me the array records where the function is equal to the register or query and not just one or the other.
I don’t quite understand what you want to do... from the looks of it, you have two pieces of information in your
data()
, being the programs and the filter, right? and want to see if the item (program) has the function? But it runs only once and gives only the first result, is that your problem? (That’s what I was able to notice)– Pliavi
I mean, it wants to keep only the functions initiated in filter? You can place the array/object programs in the question?
– Pliavi