我无法将 json 解析为模型。
这是JSON:
[
{
"name": "Douglas Crockford",
"email": "example@gmail.com",
"_id": "50f5f5d4014e045f000002",
"__v": 0,
"items": [
{
"cena1": "Cena1",
"cena2": "Cena2",
"cena3": Cena3,
"cena4": "Cena4",
"cena5": "Cena5",
"cena6": Cena6,
"_id": "50ee3e782a3d30fe020001"
}
]
}
]
我需要一个模型来拥有这样的“项目”属性:
cena = new Model({
cena1: "Cena1",
cena2: "Cena2",
...
});
我试过的:
var cenaCollection = new Backbone.Collection.extend({
model: Cenas,
url: '/orders',
parse: function (response) {
return this.model = response.items;
}
});
然后我创建集合的新实例并获取,但我得到“response.items”总是“未定义”:|
提前致谢!