I find myself filling a list using v-fordicha list is filled by an object object.
{
id1:{
descripcion: "Lorem ipsum dolor sit amet, consectetur adipisci"
imagen: "https://source.unsplash.com/random"
nivel: 1
nombre: "Carpinteria"
recomendada: true
},
idcat1: {
descripcion: "Lorem ipsum dolor sit amet, consectetu"
imagen: "https://source.unsplash.com/random"
nivel: 1
nombre: "Arquitectura"
recomendada: false
}
}
The detail is that said list must be filtered through the 'recommended' property. That is to say, I must create another object of objects but only of the recommended property = true.
Do it directly on the component with v-if. But I get a message that preferably uses a computed and that said computed return object objects already filtered and travel that object.
Try the following but it did not work:
computed:{
categoriasFiltradas(){
let vm = this;
let newObj = {};
for(let key in vm.listado_categorias){
let obj = vm.listado_categorias[key];
if(obj.recomendada == false){
//here you save the filtered object
return newObj[key] = obj;
}
}
}
},
How would that function be, thank you very much