【发布时间】:2013-07-14 22:51:06
【问题描述】:
我想从我的 users.json 中获取成功属性。我怎样才能访问它?此代码来自here。
{
"success": true,
"users": [
{
"firstName": "Tommy",
"lastName": "Maintz",
"age": 24,
"eyeColor": "green"
},
{
"firstName": "Aaron",
"lastName": "Conran",
"age": 26,
"eyeColor": "blue"
},
{
"firstName": "Jamie",
"lastName": "Avins",
"age": 37,
"eyeColor": "brown"
}
]
}
代码:
// Set up a model to use in our Store
Ext.define("User", {
extend: "Ext.data.Model",
config: {
fields: [
{name: "firstName", type: "string"},
{name: "lastName", type: "string"},
{name: "age", type: "int"},
{name: "eyeColor", type: "string"}
]
}
});
var myStore = Ext.create("Ext.data.Store", {
model: "User",
proxy: {
type: "ajax",
url : "/users.json",
reader: {
type: "json",
rootProperty: "users"
}
},
autoLoad: true
});
Ext.create("Ext.List", {
fullscreen: true,
store: myStore,
itemTpl: "{lastName}, {firstName} ({age})"
});
【问题讨论】:
-
你有什么错误吗?
-
不,这是有效的。但是我怎样才能访问成功属性呢?我试图在我商店的 Object 中找到它,但找不到任何东西。
-
你为什么不在代理阅读器中设置successProperty?如果您想使用成功处理异常..那么我认为您需要查看以下链接 [link1] (sencha.com/forum/…) [link2] (sencha.com/forum/…) [link3] (sencha.com/forum/…)
标签: javascript html sencha-touch store