使用backbone的Model的集合的时候使用
self.fetch({
success : function(Collection,resp){
console.log(self.length) // 0
console.log(resp) //[{},{}] 有数据
}
});
无法把数据添加到集合中。

接口我使用的是nodejs的的接口get后数据是正常的

代码我放到了git上,地址为:
后端:https://github.com/LuDongWei/demo/tree/master/node-address
前端:https://github.com/LuDongWei/demo/tree/master/backbone
在学习mvc的途中很纠结,希望帮助
Copyright 2014-2025 https://www.php.cn/ All Rights Reserved | php.cn | 湘ICP备2023035733号
你的源码里
https://github.com/LuDongWei/demo/blob/master/backbone/src/commentModel.js,第34行,你override了Collection的parse方法,然后还什么都没返回,那必然没有东西会被注入到Collection里去了。如下:既然什么都没实现,把上面这个
parse方法删掉吧,一切就正常了