【发布时间】:2019-03-11 15:06:29
【问题描述】:
我正在尝试从 ember 2 迁移到 ember 3,但计算属性有问题。
以前,我在组件中有这种计算属性:
import Ember from 'ember';
totalPrice: Ember.computed('attr1', 'attr2', function() {
return this.attr1 + this.attr2;
})
我可以在 hbs 模板中做类似的事情:
Total : {{totalPrice}}
在新版本的 ember 中,我有这个:
import { computed, set } from '@ember/object';
totalPrice: computed('attr1', 'attr2', function() {
return this.attr1 + this.attr2;
})
但在模板中,totalPrice 属性显示为[object],而不是值。我错过了什么吗?
【问题讨论】:
-
这通常是当您将承诺返回到模板时发生的情况。你的真实代码中是否偶然有
async function? -
不,我的代码中没有任何异步函数,但也许我错过了什么
-
@Gemkodor 如果您发现我的解决方案有帮助,请验证我的回答。谢谢
标签: javascript ember.js properties migration