Polymer 如何将数据推送到dom repeat
我试图将数据推送到Polymer 如何将数据推送到dom repeat,polymer,polymer-2.x,dom-repeat,Polymer,Polymer 2.x,Dom Repeat,我试图将数据推送到历史数组中,该数组将在dom repeat模板中更新 模板 <paper-button on-tap="_addToHistory">Add to History</paper-button> <template is="dom-repeat" items="{{history}}"> <h3 class="test">[[item.name]]</h3> </template> 功能 histor
历史
数组中,该数组将在dom repeat
模板中更新
模板
<paper-button on-tap="_addToHistory">Add to History</paper-button>
<template is="dom-repeat" items="{{history}}">
<h3 class="test">[[item.name]]</h3>
</template>
功能
history: {
type: Array,
value: []
}
_addToHistory() {
this.history.push({"name": "Computer"});
}
当我注销历史记录时,我会看到一个对象数组,但是当调用\u addToHistory
时,不会向dom追加任何内容
如何设置dom repeat
模板以响应对象更新?使用this.push('history',{item})
通知模板使用新数据更新