Sencha Touch - 代理
代理的基类是 Ext.data.proxy.Proxy。代理由模型和存储使用,用于处理模型数据的加载和保存。
有两种类型的代理 −
- 客户端代理
- 服务器代理
客户端代理
客户端代理包括使用 HTML5 本地存储的内存和本地存储。
服务器代理
服务器代理使用 Ajax、Json 数据和 Rest 服务处理来自远程服务器的数据。代理可以写入模型并存储在任何地方。
Ext.create('Ext.data.Store', { model: 'StudentDataModel', proxy : { type : 'rest', actionMethods : { read : 'POST' // 根据需求获取或发布类型 }, url : 'restUrlPathOrJsonFilePath', // 这里我们必须包含其余的 URL 路径 which fetches data from database or Json file path where the data is stored reader: { type : 'json', // 获取的数据类型为 JSON 类型 root : 'data' }, } });