无法更改数组中对象的属性 [英] cannot changed the property of an object inside an array

查看:194
本文介绍了无法更改数组中对象的属性的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

有一个父元素。其属性之一是一系列对象。这个数组在ready函数中初始化。这个数组的显示被传递给一个子元素。我想做的是每当更改乘数属性时更新数组中每个元素的数量。我尝试使用文档中描述的重写脏检查技术,但无法使其正常工作。我会感谢一些指导。
[plunker link] [1]

There is a parent element. One of its property is an array of objects. This array is initialised in the ready function. The display of this array is handed down to a child element. What I want to do is to update the quantity of each element in the array whenever the multiplier property changed. I tried to use the override dirty checking technique described in the docs but couldn't get it to work. I would appreciate some guidance. [plunker link][1]

[1]: http://plnkr.co/edit/pCZyUC7YtgUU8cpejNpj?p=info


推荐答案

这里是工作示例: Plunk

很少的东西被纠正一个是这样的:

Few things are corrected, one is this:

//DO not use 'this.setItems.0.quantity.value', but:
         this.set('setItems.0.quantity.value', newQuantity);
   console.log("New arr val: ");
   console.log(this.setItems[0].quantity.value);

文档:

https://www.polymer-project.org/1.0/docs/devguide/model-数据

https://www.polymer-project.org/1.0/docs/devguide/data-binding#array-binding

这篇关于无法更改数组中对象的属性的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆