Warning: file_get_contents(/data/phpspider/zhask/data//catemap/9/extjs/3.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
Extjs 延迟任务投掷';未捕获类型错误:未定义不是函数调用';在Sencha Touch 2.3中_Extjs_Sencha Touch_Sencha Touch 2_Sencha Touch 2.1 - Fatal编程技术网

Extjs 延迟任务投掷';未捕获类型错误:未定义不是函数调用';在Sencha Touch 2.3中

Extjs 延迟任务投掷';未捕获类型错误:未定义不是函数调用';在Sencha Touch 2.3中,extjs,sencha-touch,sencha-touch-2,sencha-touch-2.1,Extjs,Sencha Touch,Sencha Touch 2,Sencha Touch 2.1,我正在尝试使用Ext.util.DelayedTask来启动一些定时函数。我得到了错误未捕获类型错误:未定义不是函数调用。它来自Sencha源代码中DelayedTask.js的第126行 下面是我编写的运行任务的代码 var appView = Ext.ComponentQuery.query('.meterreadings_main')[0]; var meterList = Ext.ComponentQuery.query('.mbList[alias="meterListObject"]

我正在尝试使用
Ext.util.DelayedTask
来启动一些定时函数。我得到了错误
未捕获类型错误:未定义不是函数调用
。它来自Sencha源代码中DelayedTask.js的第126行

下面是我编写的运行任务的代码

var appView = Ext.ComponentQuery.query('.meterreadings_main')[0];
var meterList = Ext.ComponentQuery.query('.mbList[alias="meterListObject"]')[0];

var taskOne = Ext.create('Ext.util.DelayedTask', {
    scope: this,
    fn:function() {
        appView.pop();
    }
});

var taskTwo = Ext.create('Ext.util.DelayedTask', {
    scope: this,
    fn:function() {
        meterList.select(meterStore.getCurrentRecordIndex());
    }
});

var taskThree = Ext.create('Ext.util.DelayedTask', {
    scope: this,
    fn:function() {
        meterList.config.itemTapHandler(null,meterStore.getCurrentRecordIndex(), null,
            meterStore.getCurrentRecord(), null, null);
    }
});

appView.pop();
taskOne.delay(500);
taskTwo.delay(1500);
taskThree.delay(2500);

看到有什么不对劲吗?

即使ST2文档显示您可以创建一个延迟的任务,就像您当前所做的那样,但实际上您需要按以下方式执行:

var taskOne = Ext.create('Ext.util.DelayedTask', function() {
    console.log('delayed task');
}, this);
以下是您可以传递的参数,您将看到我已经包含了上述范围:

参数

fn : Function
The default function to call.

scope : Object
The default scope (The this reference) in which the function is called. If not specified, this will refer to the browser window.

args : Array
The default Array of arguments.

祝你好运

这很有效!谢谢我能想出的解决方案是扩展
Ext.util.DelayedTask
,重写
delay
函数,并更改第126行,以便它不尝试调用
fn
的容器,而是调用
fn
本身。这个方法也很有效,但是现在不必扩展这个类更好。