我试图使用Ext.util.DelayedTask
让一些定时功能消失。我收到错误Uncaught TypeError: undefined is not a function call
。它来自Sencha源代码中DelayedTask.js的第126行。 Click here to see the source.
这是我编写的运行任务的代码。
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);
看错了什么?
答案 0 :(得分:0)
尽管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.
祝你好运!