【发布时间】:2015-10-12 14:18:23
【问题描述】:
我有这样的事情:
<dom-module id="bar-foo">
<template>
<span class$="{{getState()}}">Bar Foo</span>
</template>
<script>
(function() {
class BarFoo {
beforeRegister() {
this.is = 'bar-foo';
this.properties = {
data: {
type: Object,
notify: true,
observer: '_updateData'
};
}
getState() {
if (this.data) {
return this.data.val > 0 ? 'positive' : 'negative';
}
}
}
Polymer(BarFoo);
})();
</script>
</dom-module>
现在,getState 函数只调用一次,但 data 属性每秒更新一次。 data 更改时是否可以更新 class$ 属性?
【问题讨论】:
标签: javascript data-binding polymer