0

我想从我的 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})"
});
4

1 回答 1

0

您可以通过以下方式获得成功属性

var success = myStore._proxy._reader.rawData.success;
于 2013-07-19T21:11:38.833 回答