我有两个 js 文件,其中一个视图在一个单独的文件中。我正在使用 Jasmine 单元测试对其进行测试。我在 jasmine.html 页面中包含了 js 文件。我可以访问除以下视图之外的所有内容。我面临的问题是,当我尝试从控制台访问视图时,它说 app.TodoView 不是我做错的构造函数?另外我在另一个文件中有依赖项
var app = app || {};
app.TodoView = Backbone.View.extend({
tagName: "li",
template: _.template($("#item-template").html()),
initialize: function() {
this.render();
},
render: function() {
console.log("rendering");
console.log(this.collection);
var template = _.template($("#item-template").html())
template = this.template({
persons: this.collection.toJSON()
});
$('#todo-list').html(template);
this.$el.html(template);
return this;
},
});
app.TodoView = new app.TodoView()
依赖(在另一个视图下的另一个js文件中)---- app.TodoView = new app.TodoView({ collection : data });