0
我的所有代碼都被找到並加載,但我的應用程序是mapApp.js文件從未找到,並且在嘗試使用它時總是給我一個未定義的代碼。要求JS找不到我的應用程序
我在做什麼錯?
這是我的文件夾層次
Site
|
|- JS
|- Libs
| |- * All my deps *
|
|- mapApp.JS
|
.
.
.
|- /models
|- /views
|- /collections
這是初始化require.js
我Main.js文件require.config({
baseUrl: '/ctt-ct/js/'
,urlArgs: "ts=" + (new Date()).getTime()
,paths: {
'jquery': 'libs/jquery.min'
,'underscore': 'libs/underscore-min'
,'backbone': 'libs/backbone'
,'templates': '../templates'
}
,shim: {
jquery: {
exports: '$'
}
,underscore: {
exports: '_'
}
,backbone: {
deps: ['underscore', 'jquery'],
exports: 'Backbone'
}
}
});
require([
'jquery'
,'underscore'
,'backbone'
,'mapApp'
],
function ($, _, Backbone, App) {
$; // <- working
_; // <- working
Backbone.View; // <- working
var app = new App(); // <- NOT working !!!
});
mapApp.js
require([
'jquery'
,'underscore'
,'backbone'
],
function ($, _, Backbone) {
var App = Backbone.View.extend({
el : $('#map_canvas')
,initialize : function(){
// DO a lot of stuff and don't return anything.
}
,drawData: function(){
// Do other stuff.
}
});
});
哼,你釘了它!我是否必須返回在所有類中存儲我的Backbone對象的var?像模型和收藏呢?我不喜歡那樣買像我一樣:( –
要求已經非常痛苦的IDE,特別是當你已經買了IntelliJ的150美元許可:)我不認爲你需要添加更多的混亂所有這些變量。 –