扩展如何将参数传递给 Web REST API 请求



我现在正在尝试将 Extjs 与我的项目之外的 Web rest API 连接起来。这是我的观点:

    Ext.define('mycomponents.view.comboselview', {
        extend: 'Ext.container.Container',
        id: 'comboview',
        alias: 'widget.comboview',
        xtype: 'comboview',
        requires: [
            'mycomponents.model.comboselmodel'
        ],
        items: [
            {
                xtype: 'combobox',
                reference: 'levels',
                publishes: 'value',
                fieldLabel: 'Choices',
                displayField: 'description',
                anchor: '-15',
                store: {
                    type: 'levels'
                },
                minChars: 0,
                queryMode: 'local',
                typeAhead: true,
                labelWidth: 100,
                labelAlign : 'right',
                width: 265,
                allowBlank: false
            }
        ],
        initComponent: function () {
            this.callParent(arguments);
            var that = this;
            console.log('!!!!!!!!!!!!!!!!!!!!!!>>>', that.up());
        }
});

这是我的模型:

        Ext.define('mycomponents.model.comboselmodel', {
            extend: 'Ext.data.Model',
            fields: [
                {
                     name: 'id',
                     mapping: 'pk'
                },
                {
                     name: 'description',
                     type: 'string',
                     mapping: 'description'
                },
                {
                     name: 'levelid',
                     type: 'integer',
                     mapping: 'levelid'
                },
                ...
            ]
        });

和我的商店:

Ext.define('mycomponents.store.comboselstore', {
    extend: 'Ext.data.Store',
    alias: 'store.levels',
    model: 'mycomponents.model.comboselmodel',
    storeId: 'levels',
    restful: true,
    autoLoad: true,
    proxy: {
        type: 'ajax',
        headers: {
           'Accept': '*/*',
           'Cache-Control': 'no-cache',
           'Content-Type': 'application/json',
           'Authorization': localStorage.token
        },
        extraParamas: {
           sort: 'description',
           filter: {
               idlevel: {
                   'null': -1
               }
           }
        },
        reader: new Ext.data.JsonReader({
        }),
        writer: new Ext.data.JsonWriter({
        }),
        actionMethods: {
           read: 'GET'
        },
        api: {
           read: 'apiurl',
           create: 'apiurl',
           update: 'apiurl',
           destroy: 'apiurl'
        },
        autoSave: true
    },
    constructor: function (config) {
        this.callParent([config]);
        console.log('I am entering here!!!')
    }
});

我正在尝试从我的apiurl获取资源,这是一个网络休息 api。我需要发送一些参数,这段代码向我返回所需的数据,但这种方法完全忽略了extraParamas。我无法说我进入了文档并找到了如何将 Extjs 与 rest API 一起使用,因为我无法在官方文档中找到如何做到这一点,所以,我一直在谷歌上寻找解决方案,到目前为止我所做的是从这里和那里获取代码片段。我的问题:如何将参数发送到 REST API?我做错了什么?

你的代码中有一个拼写错误,extraParamas,当它应该被extraParams

最新更新