我尝试了一个简单的示例:array binding
,computed property
和computed binding
<dom-module id="my-element">
<template>
<p>list of r:
<template is="dom-repeat" items="{{r}}">
<span>{{item}}</span>,
</template>
<p>
<p>computed property: {{length}}<p>
<p>computed value: {{_length(r)}}<p>
<button on-click='_add'>Add r</button>
</template>
</dom-module>
Polymer({
is: "my-element",
properties: {
r: {
type:Object,
value:[1,2]
},
length: {
type: Number,
computed: '_length(r)'
}
},
_length: function(r) {
return r.length
},
_add: function() {
this.push('r', this.r.length+1);
<!-- this.notifyPath('r', this.r); -->
}
});
并且无法理解,为什么repeated template
刷新push
新值,但computed propety
和computed binding
未刷新