我将Ember应用程序从1.11升级到1.13.2
我的博客最初显示了5个博客条目。它们使用以下路径加载到模型中:
import Ember from 'ember';
export default Ember.Route.extend({
model: function() {
return this.store.find('post', {limit: 5});
}
});
有一个按钮可以在控制器中加载更多条目:
loadMore: function() {
var self = this
this.store.find('post', {limit: 5,
skip: 5})
.then(function(posts) {
self.incrementProperty('page');
self.get('model').addObjects(posts);
});
}
但是,自升级以来,我在执行loadMore
后收到此错误:
TypeError: internalModel.getRecord is not a function
at Ember.ArrayProxy.extend.objectAtContent (record-array.js:84)
at _emberRuntimeSystemObject.default.extend.objectAt (ember.debug.js:35919)
at _emberRuntimeSystemObject.default.extend.objectAtContent (ember.debug.js:35780)
at _emberRuntimeSystemObject.default.extend.objectAt (ember.debug.js:35919)
答案 0 :(得分:1)
你正在使用它加载了babel的ember-cli
,不妨使用ES6语法,加载更多会变成以下内容:
loadMore() {
this.store.find('post', {
limit: 5,
skip: 5
})
.then((posts) => {
this.incrementProperty('page');
let model = this.get('model');
posts.forEach(model.pushObject.bind(model));
});
}