【发布时间】:2017-12-28 20:40:34
【问题描述】:
我被组件 js 中的值递增和递减所困扰。我在我的模板中得到了这个:
<div class="circleBase" {{action 'upHeat' device.status}}> <p> {{heat}} C </p> </div>
现在我只想在单击 div 时增加热值。我的组件如下所示:
init() {
console.log('init');
this._super(...arguments);
this.errors = [];
},
didRender() {
this.setProperties({
heat: 0
});
},
actions: {
upHeat: function(a){
this.set('heat', this.heat +1)
//or
this.setProperties({
heat: this.heat +1
});
console.log(heat);
}
}
这不起作用。每次我点击我的 div 时,热值都会增加但不会保存。我的模板仍然显示 0 作为值。
【问题讨论】:
标签: javascript ember.js ember-cli