我试图让这段代码在 ember 中工作,但它不断给我“Uncaught TypeError: Object # has no method 'get'”在线
this.get('element_id')[item.id] = true;
为什么它不能访问 element_id 哈希?
function() {
return Ember.ArrayProxy.extend({
box: null,
content: [],
element_id: {},
init: function() {
this._super();
var items = this.get( 'box' ).getData();
if ( items.get( 'length' ) ) {
this.set( '[]', items );
};
// Initialize the hash
items.forEach(function(item) {
this.get('element_id')[item.id] = true;
});
}
});
}
);