1

私はextjs4でこれを書いていました:

Ext.define('Superstore', {
    extends: 'Ext.data.Store'

    config : {
        customer : null,
    },

    applyCustomer : function (value) {
        this.customer = value;
    },

    model : 'Supermodel'

});

私はextjs6で同じことを試みましたが、成功しませんでした:'

Ext.define('Supermodel', {
    extend: 'Ext.data.Model',

    requires: ['Ext.data.reader.Json', 'Ext.data.proxy.Rest'],

    config: {
        customer: null
    },

    fields: [
        {name: 'id', type: 'string'},
        ...
    ],

    proxy: {
        type: 'rest',
        url: '/customers/{customer}/users',
        reader: {
            type: 'json'
        }

    },

    applyCustomer: function (value) {
        this.customer = value;
        this.proxy.url.replace('{customer}', value);
    }

});

彼らは魔法を取り除きましたか?または、私のコードのように私のURLを構築するための他のより良い方法はありますか? すでにいくつかのソリューションを見てきましたが、どれも私のアプリケーションに適合しませんでした。ログイン後にバックエンドから送信されるセッション経由で customerId を取得します。StoreManager 経由でストアを取得し、顧客レコードを取得してプロキシに適用します。

前もって感謝します。

4

1 に答える 1

2

値を操作する必要がない場合は、update代わりに関数を使用します。

updateCustomer: function(newValue){
    this.proxy.url.replace('{customer}', newValue);
}

(そしてapplyCustomer機能を削除します)

于 2015-09-24T08:39:47.860 に答える