我想根据employeeID 从JSON 中获取数据。这是 JSON 数据的外观:
{"empDetails":
[
{
"employeeId": 1,
"employeeName": 'Anton DSouz',
"age": 25,
"birthday": '05/05/1988',
"sex": 'Male'
},
{
"employeeId": 2,
"employeeName": 'John Hussain',
"age": 26,
"birthday": '03/25/1987',
"sex": 'Female'
}
]
}
这是我用来根据employeeID获取数据的代码:
Ext.define('EmpDetails',{
extend: 'Ext.data.Model',
fields: [
{name: 'employeeId', type: 'int'},
{name: 'employeeName', type: 'string'},
{name: 'age', type: 'int'},
{name: 'birthday', type: 'date', dateFormat: 'd/m/Y'},
{name: 'sex', type: 'string', defaultValue: 'Male'}
],
proxy: {
type: 'rest',
url: 'data.json',
format: 'json',
reader: {
type: 'json',
root: 'empDetails'
}
}
});
Ext.onReady(function(){
EmpDetails.load(1,{
success: function(empDetails){
console.log("Age: " + empDetails.get('age'));
}
});
});
但它不起作用。它正在查找的 URL 不正确:
../../Proxy/data.json/1.json
1.json 根本不存在,i 是data.json 中存在的employeeID。
请帮忙