Ember.js 设置作为数组的计算属性
是一种设置返回数组的计算属性的方法吗?在下面的示例中,当添加/删除新的参与者ID时,会调用get函数,但不会调用set函数Ember.js 设置作为数组的计算属性,ember.js,Ember.js,是一种设置返回数组的计算属性的方法吗?在下面的示例中,当添加/删除新的参与者ID时,会调用get函数,但不会调用set函数 participantIds: computed({ get() { Ember.debug('Getting...'); return this.get('participants').mapBy('id'); }, set(key, participantIds) { Ember.debug('Se
participantIds: computed({
get() {
Ember.debug('Getting...');
return this.get('participants').mapBy('id');
},
set(key, participantIds) {
Ember.debug('Setting...');
// do something when participants ids changed
return participantIds;
}
}),
这是因为计算属性本身没有被修改,但是返回的数组被修改了 你想要什么,可以用一个,但我不推荐这个 以一种您不需要的方式重构可能更好