我正在使用Ext js rest代理对rest API执行crud选项。 在存储和服务器之间同步数据时,代理使用客户端请求URL而不是代理中定义的休息URL,同时从存储中删除数据。
模特课程:
Ext.define('RestroApp.model.Restro', {
extend:'Ext.data.Model',
alias:'model.restro',
idProperty:'restroId',
identifier: 'sequential',
fields:[
{name:'restroName', type:'string'},
{name:'address', type:'string'},
{name:'restroId', type:'string'},
{name:'latitute', type:'int'},
{name:'longitute', type:'int'},
{name:'isVeg', type:'boolean'}
]
});
商店类:
Ext.define('RestroApp.store.RestroStore', {
extend:'Ext.data.Store',
storeId:'restostore',
alias:'store.restrostore',
requires:['RestroApp.model.Restro'],
model:'RestroApp.model.Restro',
proxy:{
type:'rest',
api:{
read:'http://localhost:12080/restro/list',
create: 'http://localhost:12080/restro/add',
update:'http://localhost:12080/restro/update',
destory:'http://localhost:12080/restro/delete'
},
reader:{
type:'json'
},
writer:{
type:'json'
}
},
autoLoad:true
});
我在http://localhost:8007上运行我的分机 在http://localhost:12080
上休息时离。的ViewController
Ext.define('RestroApp.view.main.RestroListController', {
extend:'Ext.app.ViewController',
alias:'controller.restrocontroller',
requires:['RestroApp.model.Restro'],
refreshData: function (){
var store=Ext.getStore('restostore');
store.removeAt(0);
store.sync();
}
});
与从商店删除数据时一样,它会产生错误 DELETE localhost:8007/3?_dc = 1494918882624 405(此URL不支持Http方法DELETE) 并配置的URL是localhost:12080 / restro / delete
答案 0 :(得分:1)
You have a typo on the destroy api property - "destory".