没有,你就需要在项目(或在这种情况下,其子属性)使用computed binding:
// template
<template is="dom-repeat" items="{{_myFiles}}" as="file">
<span>{{_formatDate(file.createDate)}}</span>
</template>
// script
Polymer({
_formatDate: function(createDate) {
return /* format createDate */;
}
});
或者,你可以使用一个计算的属性(如命名为_myFiles
)在myFiles
阵列,这将处理dom-repeat
迭代之前的所有项目:
// template
<template is="dom-repeat" items="{{_myFiles}}" as="file">
<span>[[file.createDate]]</span>
</template>
// script
Polymer({
properties: {
myFiles: Array,
_myFiles: {
computed: '_preprocessFiles(myFiles)'
}
},
_preprocessFiles: function(files) {
return files.map(x => {
x.createDate = /* format x.createDate */;
return x;
});
}
});
我不得不定义我的计算性能为这样: MYFILES:{ type:Array, computed:'_preprocessFiles(myFiles)', notify:true } –