2

WorkoutオブジェクトとオブジェクトがありWorkoutSectionます。どちらも、さまざまな属性にもう一方を使用します。はロード中には使用Workoutしませんが、ロード中に使用します。WorkoutSectionWorkoutSectionWorkout

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 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();
});

ありがとう!

4

1 に答える 1

1

次のいずれかをお勧めします。

  1. ここに記載されている形式に作り直しWorkoutSection.jsてみてください: http://requirejs.org/docs/api.html#cjsmoduleCommonJS

  2. models/WorkoutSectionの依存関係として完全に除外するWorkout.js

于 2012-06-23T20:58:51.780 に答える