gpt4 book ai didi

node.js - 在 Backbone.js 中创建集合时出现 TypeError : d. 集合未定义错误

转载 作者:太空宇宙 更新时间:2023-11-03 23:44:12 25 4
gpt4 key购买 nike

我是 Backbone.js 的新手。我尝试在 Backbone 中创建集合,但在创建时出现错误,因为“d.collection 是未定义错误”。

    $(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 中的快速路由方法结果。我该如何处理..

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();
});

最佳答案

我遇到了这个错误,并发现当您从头包含中删除backbone.localStorage-min.js 时,它就会消失。

关于node.js - 在 Backbone.js 中创建集合时出现 TypeError : d. 集合未定义错误,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/16819973/

25 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com