Require.js没有找到依赖项

时间:2013-07-30 22:01:35

标签: backbone.js requirejs gruntjs

我正在使用require.js,在我的配置文件中,我调用以下内容来启动应用程序(使用此页面作为参考:http://backbonetutorials.com/organizing-backbone-using-modules/):

require(['backbone', 'jquery', 'app'], function(Backbone, $, App) {
    console.log('no dependancies loaded');
});

然而,当它符合(通过grunt.js)它不加载主干和jquery - 它甚至没有列出任何依赖。但是,如果我删除应用程序需要主干和jquery加载,例如:

require(['backbone', 'jquery'], function(Backbone, $) {
    console.log('dependancies loaded');
});

main.js

require.config({
    paths: {
        jquery: 'vendor/jquery',
        underscore: 'vendor/underscore',
        backbone: 'vendor/backbone'
    },
    shim: {
        jquery: [],
        backbone: {
            deps: ['vendor/underscore', 'vendor/jquery'],
            exports: 'Backbone'
        },
        underscore: {
            exports: '_'
        }
    }
});

require(['backbone', 'jquery', 'App'], function(Backbone, $, App) {

    App.initialize();

});

app.js

define(['jquery', 'underscore', 'backbone', 'router'], function($, _, Backbone, Router){
  var initialize = function() {
    // Pass in our Router module and call it's initialize function
    Router.initialize();
  };

  return {
    initialize: initialize
  };
});

未显示任何错误消息。为什么不接他们?

1 个答案:

答案 0 :(得分:0)

Xylar,改变垫片骨干 - “deps:['下划线','jquery']