绿色框使用toJSON()输出的是object{}
但是在这之前输出都是同类型;有人知道原因么
通过一些方法看到以下这个,结果还是一样(不过object{}是可以的)
var model = Backbone.Model.extend({
url:'data/cutprice.json',
parse: function(response) {
console.log(response);//这个方法输出的object{这里有值的}
return response;
}
});
无奈之下采取了这个方法:
var t=this;
t.model.fetch({
success:function(model, text){
t.$el.html(t.template(text));//可以获得url的json数据并且渲染页面;
},
error:function(){
alert("报错!");
}
})
希望有大神可以有办法让我直接用toJSON()读取模型的值;
Copyright 2014-2025 https://www.php.cn/ All Rights Reserved | php.cn | 湘ICP备2023035733号
走同样的路,发现不同的人生