我想从我的 users.json 中获取成功属性。我怎样才能访问它?这段代码来自这里。
{
"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})"
});