【问题标题】:Uncaught TypeError when loading store in button handler function在按钮处理程序函数中加载存储时未捕获的 TypeError
【发布时间】:2016-08-12 07:18:47
【问题描述】:

在按钮处理函数中加载存储时,我得到了 Uncaught TypeError, 我的有什么问题吗 代码:

{
    xtype: 'button',
    text: 'Click me',
    handler: function() {
        var store = Ext.create('Ext.data.Store', {
            autoLoad : true,
            proxy: {
                type: 'ajax',
                url : 'MyUrl'
            }
        });
    }
}

错误信息:

Uncaught TypeError: instance[configPropMap[name].names.get] is not a function

调试器截图:

name is async

but instance has no getAsync function

【问题讨论】:

  • ext-all-rtl-debug.js出现错误,不知道叫什么名字
  • 打破错误,查看调试器。
  • nameasync,但instance 没有getAsync 功能

标签: extjs6-classic


【解决方案1】:

我有一个解决方案,使用下面的syncajax 而不是proxy.ajax

Ext.define('MyApp.store.proxy.SyncAjax', {
extend : 'Ext.data.proxy.Ajax',
alias  : 'proxy.syncajax',

config : {
    async : false
},

buildRequest : function() {
    var me      = this,
        request = me.callParent(arguments);

    request.defaultConfig.async = me.getAsync();
    request.getAsync = function() {
        request.getAsync = null;
        return me.getAsync();
    };

    return request;
}});

【讨论】:

    猜你喜欢
    • 2020-06-26
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    相关资源
    最近更新 更多