Polymer - this.push() 不会将新数组添加到现有数组中

问题描述

在 dom-repeat 中,从名为 serviceType 的下拉列表中通过 id 选择服务后,将添加这些服务。现在我尝试在 polymer 中使用 this.push() 方法来保留现有的服务数组,并根据需要向其中添加新的服务。我在 polymer 中学到了这一点,我们有很多数组变异方法,而 this.push() 就是其中之一。我可以看到新项目 (id) 被添加到 console.log 中的数组中,但它们不会在 UI 中更新。这是我的代码

_addServiceTypeId() {
var currentDetails = this._contractAttributes.serviceTypeDetails;
console.log(currentDetails)
details = []
for (var i = 0; i < currentDetails.length; i++)
    this.push('currentDetails',_contractAttributes.serviceTypeIds);
    console.log(this._contractAttributes.serviceTypeIds)
return this._contractAttributes.serviceTypeIds
}

解决方法

暂无找到可以解决该程序问题的有效方法,小编努力寻找整理中!

如果你已经找到好的解决方法,欢迎将解决方案带上本链接一起发送给小编。

小编邮箱:dio#foxmail.com (将#修改为@)