Javascript Backbone.js fetch()在服务器实例中返回对象而不是子对象,但在本地实例中检索子对象
我有两个例子。我的本地应用程序使用OS Win7,服务器实例使用OS Linux 我获取JSON数据并使用以下代码将其设置为模型Javascript Backbone.js fetch()在服务器实例中返回对象而不是子对象,但在本地实例中检索子对象,javascript,json,backbone.js,Javascript,Json,Backbone.js,我有两个例子。我的本地应用程序使用OS Win7,服务器实例使用OS Linux 我获取JSON数据并使用以下代码将其设置为模型 var RModel = Backbone.Model.extend({ idAttribute: 'name', parse: function (response) { return {
var RModel = Backbone.Model.extend({
idAttribute: 'name',
parse: function (response) {
return {
'name': response.name,
'title': response.title,
'description': response.description,
'parameters': new ParamsList(response.parameters)
};
}
});
that.model = new RModel();
that.model.url = "url/" + '?limited=false';
that.model.fetch({
cache: false
}).done(function() {
that.headerTemplate = that.headerTemplateEdit;
that.bodyTemplate = that.bodyTemplateEdit;
that.footerTemplate = footerTemplate;
that.load({});
});
在我的本地实例中,以下代码在控制台中的结果
this.model
child
_changing:false
_pending:false
_previousAttributes:Object
attributes:Object
changed:Object
cid:"c217"
id:"testUndefinedParam"
url:"/url?limited=false"
__proto__:
Backbone.Model
在服务器实例中
this.model
i
_changing: false
_pending: false
_previousAttributes: Object
attributes: Object
changed: Object
cid: "c25920"
id: "testDateError2"
url: "/url?limited=false"
__proto__: t.Model
如果有人遇到这个问题,请说明正确检索JSON数据的方法。我猜您的服务器中的代码已被处理(minify/uglify),而本地服务器中的代码未被处理。因此,处理器刚刚将
child
重命名为i
,Backbone
重命名为t
等。您应该关注实际数据的差异,而不是控制台输出的构造函数名称。据我所知,没有标准,不同浏览器的标准可能不同您在检索数据时遇到了什么问题?数据位于模型属性中。子项
来自主干本身。这就是它的名字。