我是 Backbone.js 的新手,我有一个数据集,分配给查看,但我无法获取数据,同时我控制台任何人告诉我我的代码有什么问题?
代码:
var model = Backbone.Model.extend({
data:[
{text:'Google',href:"http://www.google.com"},
{text:'Yahoo',href:"http://www.yahoo.com"},
{text:'Bing',href:"http://www.bing.com"}
]
});
var View = Backbone.View.extend({
initialize:function(){
this.render();
},
render:function(){
var data = this.model.get('data');
console.log(data);
}
});
var myView = new View({model:model});
我得到的错误在这里:
TypeError: this.model.get is not a function
[Break On This Error]
var data = this.model.get('data');