我在我的移动应用项目中使用backbone.js和underscore.js。我的问题是如何识别每个文件的javascript依赖项?我尝试使用下面的代码,但仍然无法在浏览器中使用。
require.config({
waitSeconds: 0,
//path mappings for module names not found directly under baseUrl
paths: {
jquery: 'vendor/jqm/jquery_1.7_min',
jqm: 'vendor/jqm/jquery.mobile-1.4.0-rc.1',
underscore: 'vendor/underscore/underscore_amd',
backbone: 'vendor/backbone/backbone_amd',
jqueryflexslider: 'vendor/lib/jquery.flexslider',
shCore: 'vendor/lib/shCore',
shBrushXml: 'vendor/lib/shBrushXml',
shBrushJScript: 'vendor/lib/shBrushJScript',
jqueryeasing: 'vendor/lib/jquery.easing',
jquerymousewheel: 'vendor/lib/jquery.mousewheel',
demo: 'vendor/lib/demo',
text: 'vendor/require/text',
plugin: 'plugin',
main: 'main',
messages: 'messages',
templates: '../templates',
modules: '../modules',
model: '../model'
},
shim: {
'backbone': {
deps: ['underscore', 'jquery'],
exports: 'Backbone'
},
'jquery': {
exports: '$'
},
'jqm': {
deps: ['jquery'],
exports: '$'
},
'jqueryflexslider': {
deps: ['jquery'],
exports: '$'
},
'jqueryeasing': {
deps: ['jquery'],
exports: 'jQuery'
},
'jquerymousewheel': {
deps: ['jquery'],
exports: '$'
},
'demo': {
deps: ['jquery'],
exports: '$'
},
'main': {
deps: ['jquery'],
exports: '$'
},
'messages': {
deps: ['jquery'],
exports: '$'
},
'underscore': {
exports: '_'
},
}
});
//1. load app.js,
//2. configure jquery mobile to prevent default JQM ajax navigation
//3. bootstrapping application
define(['app', 'jqm-config'], function(app) {
$(document).ready(function() {
console.log("DOM IS READY"); // Handler for .ready() called.
});
app.initialize();
});
参考:https://github.com/woothemes/FlexSlider/blob/master/demo/index.html
请建议我。