4

我从这个问题中遇到了完全相同的问题。但是我使用的是 Sencha Touch 2,但我不知道如何实际使用这个自定义商店。我在模型类中定义了我的 REST 代理。我将如何访问/使用此自定义代理?

proxy: {
    type: 'rest',
    url: 'http://someUrl', 
    reader: {
        type: 'json',
    }
}
4

1 回答 1

10

在 Sencha Touch 2 中它相当简单。这假设你有一个 MVC 架构。

首先,你建模 - app/model/Image.js

Ext.define('MyApp.model.Image', {
    extend: 'Ext.data.Model',

    // Require your custom proxy
    requires: ['MyApp.proxy.MyCustomProxy'],

    config: {
        fields: ['name'],

        proxy: {
            // set the type of your proxy
            type: 'mycustomproxy'
        }
    }
});

然后定义您的代理 - app/proxy/MyCustomProxy.js

Ext.define('MyApp.proxy.MyCustomProxy', {
    extend: 'Ext.data.proxy.Proxy',

    // Set your proxy alias
    alias: 'proxy.mycustomproxy',

    ...
});
于 2012-02-12T22:52:08.000 回答