我有一个包含ID,名称,类别和5个数据的产品数组。假设有3个产品分配给移动类别,其中两个是计算机类别。 什么是将这三种产品呈现在同一类别“移动设备”上的正确方法
let array_e = this.E_Product; //products array
array_e.forEach((element) => {
var obj = _.find(array_e, (find) => find.category == 'mobile');
console.log(obj);
});
在数组上查找对象仅显示一个首先捕获的对象。
答案 0 :(得分:1)
只需使用计算的属性并将其值提供给v-data-table
或v-list
组件:
computed:{
mobileProducts(){
return this.E_Product.filter(prod=>prod.category == 'mobile');
}
}
答案 1 :(得分:1)
使用过滤器
session()->flash('message', $message);