我是新来"需要JS"的 但好像撞到砖墙了
麻烦从我的“ 应用程序” 模块开始。 我不知道如何告诉 RuppJS 装入我的叶模块 - 取决于“ 应用程序” 的软件包 。
我想我知道为什么, 因为系统中没有任何东西取决于他们, 他们也没有注册, 但我需要处理这个案子。
我怎么能让"需要"JS知道这些模块 并适当装载它们呢?
干杯 干杯
//index.html
....
<script data-main="app/config" src="/assets/js/libs/require.js"></script>
....
//config.js
require.config({
deps: [ "app" ],
paths: {
libs: "../assets/js/libs",
plugins: "../assets/js/plugins",
jquery: "../assets/js/libs/jquery",
underscore: "../assets/js/libs/underscore",
backbone: "../assets/js/libs/backbone",
marionette: "../assets/js/libs/backbone.marionette"
}
});
//app.js
require(
[ "jquery", "underscore", "backbone", "marionette" ],
function ( $, _, Backbone, Marionette ) {
//....
}
);
//app.view.js
require(
[ "jquery", "underscore", "backbone", "marionette", "app" ],
function ( $, _, Backbone, Marionette, App ) {
//....
}
);
//app.route.js
require(
[ "backbone", "app" ],
function ( Backbone, App ) {
//....
}
);
因此:
- app.js depends on "jquery", "underscore", "backbone", "marionette"
- app.view.js depends on "jquery", "underscore", "backbone",
- "marionette", "app" app.route.js depends on "backbone", "app"