我有一个对象数组如下:
products = [
{
id: 1,
title: "Product 1",
specifications: {
price: 1.55,
discount: 15,
attributes: [
{
l1: 100,
l2: 80
height:200,
weight: 15,
parameters: [
{
id: 199199 // this is how I identify the parameter
size: 185 // this is what I want to change
}, ...
]
}, ...
]
}
}, ...
]
我有一个参数变化的数组,例如:当product.specifications.attributes.parameters.id == 199199时,将大小更改为189。
我想在不展平任何元素的情况下完成此操作,因为它们是Vue.js数据结构的一部分,展平会破坏响应性。
我应该如何做?我可以使用Underscore或lo-dash。