我有一个数组graphData。现在我想用dom-重复打印它。
<template is='dom-repeat' items='{{internalgraphData}}'>
<tr>
<td>{{item.asset}}</td>
<td>{{item.percentage}}%</td>
<td>{{item.investment}}</td>
<td>{{item.currentvalue}}</td>
<td class="u-value-align"><span class="red-text darken-4">{{item.gain}}</span></td>
<td><img src="../images/arrow-red.png"></td>
<td class="black-text"><a class="waves-effect waves-light btn white blue-text back" href="equity.html">Select</a></td>
</tr>
</template>我的儿子如下..。我尝试用下面的标签值"internalgraphData“创建dom-重复结构,我打印了internalgraphData,看起来我成功地将数据从json传输到本地标记值结构"internalgraphData”。
Polymer({ is: 'my-menu',
........
ready : function(graphid,graphData) {
this.graphData = [
['Equity', 50,25000,37000,240],
['Bonds', 35,12500,10000,-480],
['Alternates',5, 2000,2000,340],
['Cash',10,1000,1000,-140]
];
if (this.graphData.length > 0)
{
for(i = 0; i< this.graphData.length; i++)
{
this.internalgraphData.push({
"asset" : this.graphData[i][0],
"percentage" : this.graphData[i][1],
"investment" : this.graphData[i][2],
"currentvalue" : this.graphData[i][3],
"gain" : this.graphData[i][4]
});
}但我看到,重复并不是打印。谁能帮上忙,我们怎么做到呢?
注意:如果我显式地添加标记值.桌子来了..。
this.internalgraphData = [
/*['Equity', 50,25000,37000,240],
['Bonds', 35,12500,10000,-480],
['Alternates',5, 2000,2000,340],
['Cash',10,1000,1000,-140]*/
{asset: 'Equity', percentage: 50, investment: 25000, currentvalue: 37000, gain: 240 },
{asset: 'Equity', percentage: 35, investment: 12500, currentvalue: 10000, gain: -480 },
{asset: 'Equity', percentage: 5, investment: 2000, currentvalue: 2000, gain: 340 },
{asset: 'Equity', percentage: 10, investment: 1000, currentvalue: 1000, gain: -140 }
];发布于 2016-08-04 11:30:05
this.internalgraphData.push({});以上循环操作不反映聚合物数据的变化,下面是阵列对象的推荐方法。
如果你不能这样做的话,this.push('internalgraphData', {title:'hey'});。请用下面的方式
this.updatedgraphData = JSON.parse(JSON.stringify(this.internalgraphData ));在***updatedgraphData***上使用dom-重复
https://stackoverflow.com/questions/38765558
复制相似问题