我遇到了 RequireJS 的问题,给了我一些“未捕获的 TypeError”,我所拥有的只是基本结构,当我在波纹中测试它时,我经常得到这个。
Uncaught TypeError: Cannot call method 'local_data_exist' of undefined
这是我的一个库中的一个函数。
Uncaught TypeError: Cannot read property 'jqmNavigator' of undefined
或这个。
因此,由于错误不一致,它们让我很难调试。想知道是否有人以前遇到过这种情况。
require.config({
deps:['main'],
baseUrl: "js",
paths:{
// Pointing to Main possible fix for random undefined
app: 'main',
// jQuery
jquery:'libs/jquery/jquery-1.9.1.min',
// jQuery Plugin for Dfp
dfp: 'libs/jquery/jquery.dfp.min',
// jQuery Mobile framework
jqm:'libs/jquery.mobile/jquery.mobile-1.3.0.min',
// Backbone.js library
Backbone:'libs/Backbone/Backbone',
// Backbone.js Adapter
localStorage: 'libs/Backbone/backbone.localStorage',
// RequireJS plugin
text:'libs/require/text',
// RequireJS plugin
domReady:'libs/require/domReady',
// underscore library
underscore:'libs/underscore/underscore',
// jQuery Mobile plugin for Backbone views navigation
jqmNavigator:'libs/jquery.mobile/jqmNavigator',
//TouchSwipe
touchSwipe: 'libs/jquery/jquery.touchSwipe.min',
//Moment (Date Plugin)
moment: 'libs/moment/moment',
// Language plugin
lang: 'libs/moment/langs.min',
// Utility Lib
utils: './utils'
},
shim:{
Backbone:{
deps:['underscore', 'jquery'],
exports:'Backbone'
},
app: {
deps:['jquery','Backbone','underscore'],
exports: "App"
},
underscore:{
exports:'_'
},
dfp : {
deps:['jquery']
},
jqm:{
deps:['jquery', 'jqm-config', 'jqmNavigator']
},
touchSwipe:{
deps:['jquery']
},
lang:{
deps:['moment']
},
utils:{
deps:['jquery']
}
},
waitSeconds: 200,
priority: ['jquery']
});
require(['jquery', 'domReady', 'Backbone', 'jqm-router', 'models/ApiModel', 'jqm', 'underscore', 'jqm-config', 'jqmNavigator'],
function ($, domReady, Backbone, AppRouter, Api) {
domReady(function(){
window.Api = Api;
$(this).router = new AppRouter();
});
}
);