我正在尝试使用Ext.util.DelayedTask
来关闭一些定时函数。我得到了错误Uncaught TypeError: undefined is not a function call
。它来自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.
祝你好运!