0

ここに私のコンソールにスローされたエラーがあります

Uncaught TypeError: Object  has no method 'chain' hbs.js:282
getExternalDeps hbs.js:282
(anonymous function) hbs.js:306
xhr.onreadystatechange hbs.js:73
Uncaught Error: Load timeout for modules: hbs!templates/reset_unnormalized2,hbs!templates/pages/login_unnormalized3,hbs!templates/reset,hbs!templates/pages/login
http://requirejs.org/docs/errors.html#timeout require.js:160

私は handlebars-require-plugin を使用しており、require shim に「hbs」を追加しようとしましたが、結果は同じです。

ここに私のマリオネットビューコードがあります:

define([
    "bootstrap", // bootstrap does not export anything, so no arg sent to our function
    "marionette", 
    "session", "events",
    "hbs!templates/pages/login"
], function( Marionette, Session, Events, LoginTemplate ){
    return Marionette.View.extend({
        template : {
            type : "handlebars",
            template : LoginTemplate
        }
    });
});

ここで何が起こっているのかわかりません。検索を行っても、有用な結果は得られませんでした。

何が起こっていますか?なぜこうなった?助けてください。

4

2 に答える 2

3

コールバックへの引数が正しく定義されていない可能性がありますか? 値が何も定義していない場合 (ブートストラップなど)、それを最後にします。現在、マリオネット引数にはブートストラップの未定義の値が含まれており、セッションはマリオネットなどを保持しています.

define([
    "marionette", 
    "session", "events",
    "hbs!templates/pages/login",
    "bootstrap", // bootstrap does not export anything, so no arg sent to our function
], function( Marionette, Session, Events, LoginTemplate ){
    return Marionette.View.extend({
        template : {
            type : "handlebars",
            template : LoginTemplate
        }
    });
});
于 2013-01-14T13:46:56.513 に答える
0

私はそれを考え出した。

hbs私の問題は、プラグイン、ハンドルバー、およびrequirejsでjson2を使用していたため、プラグインに関連していないことがわかりました。

最初の問題は、上記のように、lodashライブラリを で切り替えることによって解決されましたunderscore。私はこれらの 2 つが交換可能であるという印象を受けていましたが、どうやらそうではないようです。

その後、エラーが発生したため、内部で定義されていないことが"stringify" is not a function on the object nullわかりました。JSONhbs

私は自分に戻ってrequire.config({ shim:{} })、のエクスポートでjson2を定義する必要がありましたJSON

今はエラーが発生していませんがhbs、ビューが表示されない理由を理解する必要があります。

これが私の設定コードです。他の誰かが興味を持っているはずです。

require.config({
    // paths to required javascript files
    paths : {
        bootstrap   : "../assets/js/bootstrap.min",
        jquery      : "../assets/js/jquery.min",
        json2       : "../assets/js/json2",
        underscore  : "../assets/js/underscore.min",
        backbone    : "../assets/js/backbone.min",
        marionette  : "../assets/js/backbone.marionette.min",
        hbs         : "../assets/js/hbs",
        handlebars  : "../assets/js/handlebars",
        i18nprecompile : "../assets/js/hbs/i18nprecompile"
    },

    // "shim" will allows us to load in deps synchronously so that we do not
    // run into a situation where dependencies are not available
    shim : {
        json2       : { exports : "JSON" },
        jquery      : { exports : "jQuery" },
        underscore  : { exports : "_" },
        backbone    : {
            deps : ["jquery", "underscore", "json2"],
            exports : "Backbone"
        },
        marionette  : {
            deps : ["jquery", "underscore", "json2", "backbone"],
            exports : "Marionette"
        },
        hbs : {
            deps : ["jquery", "underscore", "json2", "i18nprecompile", "handlebars"],
            exports : "hbs"
        },
        bootstrap : { deps : ["jquery"] }
    }
});
于 2013-01-14T19:48:45.097 に答える