Javascript Polymer 1.0:绑定css类不会更新

Javascript Polymer 1.0:绑定css类不会更新,javascript,data-binding,polymer,Javascript,Data Binding,Polymer,我有这样的想法: <dom-module id="bar-foo"> <template> <span class$="{{getState()}}">Bar Foo</span> </template> <script> (function() { class BarFoo { beforeRegister() {

我有这样的想法:

<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>

巴福
(功能(){
巴福级{
注册前{
this.is='bar-foo';
此属性={
数据:{
类型:对象,
通知:正确,
观察者:“_updateData”
};
}
getState(){
如果(这个数据){
返回this.data.val>0?'positive':'negative';
}
}
}
聚合物(巴福);
})();

现在,
getState
函数只调用一次,但是
data
属性每秒更新一次。当
data
更改时,是否可以更新class$属性?

如果希望每次
data.val
更改时都对
getState
函数求值,可以将其作为参数t传递o功能

<span class$="{{getState(data.val)}}">Bar Foo</span>
Bar-Foo

查看以获取有关计算绑定的详细信息。

如果希望每次
data.val
更改时都对
getState
函数求值,可以将其作为参数传递给该函数

<span class$="{{getState(data.val)}}">Bar Foo</span>
Bar-Foo
有关计算绑定的更多信息,请参阅