需要使用Backbonejs - "使用严格"抛出错误

时间:2014-05-14 09:33:48

标签: javascript backbone.js requirejs strict

我正在使用Backbone.Marionette开发一个应用程序,我使用RequireJs加载文件,我决定对我的应用程序使用严格模式,所以我声明了

“使用严格”功能。但是我得到这样的错误:

ught TypeError: Cannot set property 'App' of undefined 

当我从功能中删除“use strict”时,一切正常。

这是我的功能:

define(["jQuery", "underscore", "backbone", "marionette","routes"], 
    function($, _, Backbone, Marionette, Routes){

        "use strict";

        console.log(Marionette);

        this.App = new Marionette.Application();

        this.App.addInitializer(function(){
            var Route = new Routes();
            Backbone.history.start();
        });

        this.App.start();


}); 

这里有什么问题?如何解决这个问题或如何将严格模式应用于我的函数?

1 个答案:

答案 0 :(得分:0)

如果将其添加到主文件或配置文件中,则可以将该窗口用作依赖项。

define('window',[],function(){return window;});