Warning: file_get_contents(/data/phpspider/zhask/data//catemap/0/backbone.js/2.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181

Warning: file_get_contents(/data/phpspider/zhask/data//catemap/2/batch-file/6.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
Javascript 视图不是Typescript下主干的构造函数_Javascript_Backbone.js_Typescript - Fatal编程技术网

Javascript 视图不是Typescript下主干的构造函数

Javascript 视图不是Typescript下主干的构造函数,javascript,backbone.js,typescript,Javascript,Backbone.js,Typescript,我正在尝试在Typescript中创建Backbone.js视图。我得到以下错误: TypeError: ExampleView is not a constructor in http://localhost:57258/Tests/spec/ExampleViewTest.js (line 17) 我的视图是这样实例化的: var view = new ExampleView(); ///<reference path="../Scripts/typings/backbone/ba

我正在尝试在Typescript中创建Backbone.js视图。我得到以下错误:

TypeError: ExampleView is not a constructor in http://localhost:57258/Tests/spec/ExampleViewTest.js (line 17)
我的视图是这样实例化的:

var view = new ExampleView();
///<reference path="../Scripts/typings/backbone/backbone.d.ts"/>

class ExampleView extends Backbone.View {   
    constructor(options?: Backbone.ViewOptions) {
        super(options);
    }
};
视图声明如下:

var view = new ExampleView();
///<reference path="../Scripts/typings/backbone/backbone.d.ts"/>

class ExampleView extends Backbone.View {   
    constructor(options?: Backbone.ViewOptions) {
        super(options);
    }
};
主干未定义。我如何导入它

var __extends = this.__extends || function (d, b) {
    for (var p in b) if (b.hasOwnProperty(p)) d[p] = b[p];
    function __() { this.constructor = d; }
    __.prototype = b.prototype;
    d.prototype = new __();
};
var ExampleView = (function (_super) {
    __extends(ExampleView, _super);
    function ExampleView() {
        _super.apply(this, arguments);
    }
    return Av;
})(Backbone.Model);
//# sourceMappingURL=av.js.map

使用脚本标记。或者像
requirejs
这样的外部模块加载器以及AMD模块(
--module AMD
)。更多信息:

通常主干视图是使用
Backbone.View.extend(…)
创建的,但您似乎在使用本机JavaScript原型继承。这可能就是问题所在。您可能需要改用
Backbone.View.extend(…)
。我之所以使用“extends”关键字,是因为建议在主干的Typescript版本中使用它。他们实际上阻止了主干.View.extend(…)