我有一个Workout
对象和一个WorkoutSection
对象。两者都使用另一个属性。 Workout
在加载过程中未使用WorkoutSection
,但WorkoutSection
在加载过程中使用Workout
。
WorkoutSection.js
define(['require',
// post-load
'models/Workout'
],
function(require) {
// must require Workout because of mutual dependency
var Workout = require('models/Workout');
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 k.s.newContext.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();
});
谢谢!
答案 0 :(得分:1)
我建议你:
尝试将WorkoutSection.js
重新加工为CommonJS
格式,如下所示:http://requirejs.org/docs/api.html#cjsmodule
完全排除models/WorkoutSection
作为Workout.js
的依赖关系