我有一个父组件 Parent 和扩展 Parent 的 Child 组件。
在 Parent 中有一个返回数组的计算属性 items
。有没有办法在子组件中包含 items
,它将返回父数组中的元素和其他元素,例如
家长:
Ember.Component.extend({
items: computed(function() {
return ['a', 'b'];
})
})
child :
Parent.extend({
items: computed(function() {
// I want to add some more elements to parent property
// so this should return ['a', 'b', 'c', 'd']
return this.get('items').concat(['c', 'd']);
})
});
目前我收到 Maximum call stack size exceeded
。
最佳答案
是的!使用_super
:
Parent.extend({
items: computed(function() {
// I want to add some more elements to parent property
// so this should return ['a', 'b', 'c', 'd']
return this._super('items').concat(['c', 'd']);
})
});
这是一个有效的 twiddle .
关于javascript - Ember 扩展组件计算属性?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/50182042/