【发布时间】:2017-04-04 09:13:55
【问题描述】:
我有一个对象数组如下:
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
}, ...
]
}, ...
]
}
}, ...
]
...以及我要应用的参数更改数组,例如:将 size 更改为 189 where product.specifications.attributes.parameters.id == 199199。
我想在不展平任何元素的情况下执行此操作,因为它们是 Vue.js 数据结构的一部分,它会破坏反应性。
我怎么能这样做?我愿意使用 Underscore 或 lo-dash
【问题讨论】:
标签: javascript underscore.js vue.js lodash