1
我是Backbone.js.的新手我已經嘗試在Backbone中創建集合,同時創建我收到錯誤爲'd.collection未定義的錯誤「。獲取TypeError:d.collection在創建Backbone.js中的集合時未定義錯誤
$(function(){
var MyModel = Backbone.Model.extend();
var MyCollection = Backbone.Collection.extend({
url: '/index.html',
model: MyModel
});
var coll = new MyCollection();
coll.fetch({
error: function (collection, response) {
console.log('error', response);
},
success: function (collection, response) {
console.log('success', response);
}
});
});
此外,我需要處理在Backbone.How快遞航線方法結果我就可以搞定..
app.js
app.all('*',function(req,res){
var result={a:'a',b:'b',c:'c'};
res.writeHead(200, {'Content-Type': 'text/json'});
res.write(JSON.stringify(result));
res.end();
});
你確定它的'url:'/ index.html','?不應該是'url:'/ index.json',' – rajkamal
@rajkamal是我的網址是/index.html – sachin