在下面的代码中,导航器向我抛出了一个错误,我正在使用带有 require.js 的主干.js 从视图中加载书籍,这是我的代码:
BookListView.js
define([
'jquery',
'underscore',
'backbone',
'collections/bookCollection',
'views/bookView'
], function ($, _, Backbone, bookCollection, bookView) {
var books = [{ ... }];
var BookListView = Backbone.View.extend({
el: $('#books'),
initialize: function () {
_.bindAll(this, 'render', 'renderBook');
this.collection = new bookCollection(books);
this.render();
},
render: function () {
_.each(this.collection.models, function (item) {
this.renderBook(item);
});
},
renderBook: function (item) {
var BookView = new bookView({
model: item
});
this.$el.append(BookView.render().el);
}
});
return BookListView;
});
控制台返回错误:Object [object global] has no method 'renderBook'
请问你能帮帮我吗?