骨干视图 - 未定义

nXq*_*Xqd 8 javascript backbone.js

这真让我困惑,我觉得我很蠢,但我已经搜索过并尽我所能.每当我声明一个视图并使用jasmine运行BDD测试时,它总是返回"undefined is not a function".这是代码

window.LocationView = Backbone.View.extend({
    initialize: function() {
        // create new marker first
        this.marker = new google.maps.Marker({
            title: this.model.get('name'),
            draggable: true,
            animation: google.maps.Animation.DROP,
            position: new google.maps.LatLng(this.model.get('lat'), this.model.get('long')), // give the position here
        });

        // bind events
        this.model.bind('change', this.render, this);
    },
    render: function() {
        this.marker.setTitle(this.model.get("name"));
        this.marker.setPosition(new google.maps.LatLng(this.model.get('lat'), this.model.get('long')));
    },
});
Run Code Online (Sandbox Code Playgroud)

这是我宣布的方式:

this.view = new LocationView({model: this.location});
this.view = new LocationView();
// neither of these ones work.
Run Code Online (Sandbox Code Playgroud)

当我使用jasmine运行此代码时,这是错误:

TypeError: undefined is not a function
    at [object Object].make (http://cdnjs.cloudflare.com/ajax/libs/backbone.js/0.5.3/backbone-min.js:29:37)
    at [object Object]._ensureElement (http://cdnjs.cloudflare.com/ajax/libs/backbone.js/0.5.3/backbone-min.js:30:270)
    at [object Object].<anonymous> (http://cdnjs.cloudflare.com/ajax/libs/backbone.js/0.5.3/backbone-min.js:28:127)
    at new <anonymous> (http://cdnjs.cloudflare.com/ajax/libs/backbone.js/0.5.3/backbone-min.js:32:136)
    at [object Object].<anonymous> (http://localhost/gmap_api/public/test/spec/specs.js:62:21)
    at [object Object].execute (http://localhost/gmap_api/public/test/spec/jasmine/jasmine.js:1001:15)
    at [object Object].next_ (http://localhost/gmap_api/public/test/spec/jasmine/jasmine.js:1790:31)
    at [object Object].start (http://localhost/gmap_api/public/test/spec/jasmine/jasmine.js:1743:8)
    at [object Object].execute (http://localhost/gmap_api/public/test/spec/jasmine/jasmine.js:2070:14)
    at [object Object].next_ (http://localhost/gmap_api/public/test/spec/jasmine/jasmine.js:1790:31)
Run Code Online (Sandbox Code Playgroud)

New*_*bie 18

当我以错误的顺序包含我的javascript文件时,我遇到了类似的问题.像这样导入它们:

jQuery.js 
Underscore.js
Backbone.js
YourCode.js
Run Code Online (Sandbox Code Playgroud)

如果不是这种情况,则发布发生此异常的行.