我想知道是否有办法获取计算属性的 _super
?
例如:
controllers/core-controller.js
export default Controller.extend({
myAttribute: computed(function() {
return {
bar: this.get('bar')
};
});
});
controllers/my-controller.js
import CoreController from 'controllers/core-controller';
export default CoreController.extend({
myAttribute: computed(function() {
let super = this.get('_super') //I'm trying to get the myAttribute object from the CoreController
return merge(super, { foo: 'foo' });
});
});
最好的方法是什么?
谢谢。
最佳答案
您可以通过调用 this._super(...arguments)
来完成:
import CoreController from 'controllers/core-controller';
export default CoreController.extend({
myAttribute: computed(function() {
let superValue = this._super(...arguments);
return merge(superValue, { foo: 'foo' });
});
});
也在这个 twiddle 中演示:https://ember-twiddle.com/dba33b9fca4c9635edb0
关于javascript - Ember 计算属性 _super,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/35258849/