我有一个Workout
对象和一个WorkoutSection
对象。两者都将另一个用于各种属性。在加载期间Workout
不使用WorkoutSection
,但在加载期间WorkoutSection
使用Workout
。
锻炼节.js
define(['require',
// post-load
'models/Workout'
],
function(require) {
// must require Workout because of mutual dependency
var Workout = require('models/Workout');
锻炼.js
define([
'require','models/WorkoutSection'
],
function(require) {
// must re-require Workout because of mutual dependency
var WorkoutSection;
var Workout = Parse.Object.extend("Workout",
{
initialize : function() {
WorkoutSection = require('models/WorkoutSection');
},
错误:
未捕获的错误:尚未为上下文加载模块名称“models/Workout”:_ http://requirejs.org/docs/errors.html#notloaded require.js:2 H require.js:2 ksnewContext.j.require require.js:2 requirejs require.js:2(匿名函数) WorkoutSection.js:20
我正在遵循链接中描述的解决方案,但仍然收到错误 =S 任何可以解决此问题的想法?
这是我的 main.js:
// Filename: main.js
// Require.js allows us to configure shortcut alias
// Their usage will become more apparent futher along in the tutorial.
require.config( {
paths : {
jQuery : 'libs/jquery/jquery-min',
Underscore : 'libs/underscore/underscore-min',
Backbone : 'libs/backbone/backbone-min',
Parse : 'libs/parse/parse-min',
templates : '../templates'
}
});
require( [
// Load our app module and pass it to our definition function
'app',
],
function(App) {
// The "app" dependency is passed in as "App"
// Again, the other dependencies passed in are not "AMD" therefore
// don't pass a parameter to this function
App.initialize();
});
谢谢!