Backbone.js 主干,木偶不识别ItemView:未定义不是函数
我不明白为什么我的ItemView出现了这个错误 这是我的main.jsBackbone.js 主干,木偶不识别ItemView:未定义不是函数,backbone.js,marionette,Backbone.js,Marionette,我不明白为什么我的ItemView出现了这个错误 这是我的main.js require.config({ baseUrl: '/', paths: { jquery: 'scripts/lib/jquery/jquery.min', backbone: 'scripts/lib/backbone/backbone.min', underscore: 'scripts/lib/underscore/underscore-min',
require.config({
baseUrl: '/',
paths: {
jquery: 'scripts/lib/jquery/jquery.min',
backbone: 'scripts/lib/backbone/backbone.min',
underscore: 'scripts/lib/underscore/underscore-min',
//Core Libraries
marionette: 'scripts/lib/marionette/marionette.min',
text: 'scripts/lib/text/text',
async :'scripts/lib/async'
},
shim: {
jquery: {
exports: '$'
},
underscore: {
exports: '_'
},
backbone: {
deps: [ 'underscore', 'jquery' ],
exports: 'Backbone'
},
marionette : {
deps : ['jquery', 'underscore', 'backbone'],
exports : 'Marionette'
}
}
});
require([
'jquery',
'underscore',
'backbone',
'marionette'
], function () {
// create the app
var App = new Marionette.Application();
App.addRegions({
map : '#Map'
});
App.addInitializer( function() {
var self = this;
require(['scripts/views/map']
, function(MapView){
self.map.show( new MapView() );
});
});
App.start();
window.App = App;
});
这是我的maps.js
define([
'jquery',
'underscore',
'text!scripts/templates/map.html',
'async!https://maps.googleapis.com/maps/api/js?v=3&sensor=true'
], function($, _, mapTemplate) {
var MapView = Marionette.ItemView.extend({
template: _.template( mapTemplate ),
ui: {
mapContainer: '#map-container'
},
onRender: function() {
var self = this;
var mapOptions = {
zoom: 8,
center: new google.maps.LatLng(-34.397, 150.644),
mapTypeId: google.maps.MapTypeId.ROADMAP
};
var map = new google.maps.Map(this.ui.mapContainer, mapOptions);
}
});
return MapView;
});
我不熟悉主干线和木偶,所以我不确定为什么会出现以下错误:
未捕获类型错误:未定义不是函数
在这一行:
self.map.show( new MapView() );
您不需要“要求”木偶网(或者访问它的完全限定名称Backbone.marionete)我没有遵循,我将其定义为main.js