【发布时间】:2015-06-16 23:37:23
【问题描述】:
我有以下聚合物元素:
调用 someMethod 后,navigator.currentStep 的值没有更新。
<dom-module id="m">
<template>
Navigator step = <span>{{navigator.currentStep}}</span>
</template>
</dom-module>
Polymer({
is: 'm',
ready: function() {
this.navigator = new Navigator(1);
console.log(this.navigator.currentStep); // 1
},
someMethod: function() {
this.navigator.next();
console.log(this.navigator.currentStep); // 2
}
});
输出总是
导航步骤 = 1
但以下工作
<dom-module id="m">
<template>
Navigator step = <span>{{currentStep}}</span>
</template>
</dom-module>
Polymer({
is: 'm',
ready: function() {
this.navigator = new Navigator(1);
this.currentStep = this.navigator.currentStep; // 1
},
someMethod: function() {
this.navigator.next();
this.currentStep = this.navigator.currentStep; // 2
}
});
【问题讨论】: