我試圖用dojo fadeIn/Out產生閃爍的效果。dojo.hitch()作用域爲window.setInterval()
下面的代碼片段是一個小部件類的聲明中定義:
_startHighlightEffect : function() {
var blinkInterval = 5000; //Scope here is that of the parent widget
window.setInterval (function() {
dojo.fadeOut(
{
node: this._headerDiv.domNode,
onEnd: function() {
dojo.fadeIn({node: this._headerDiv.domNode},3000).play();
}
},3000).play();
}, blinkInterval);
},
_highlightEffect : function() {
this.func = dojo.hitch(this,this._startHighlightEffect);
this.func();
}
我面臨的問題是,它說,「this._headerDiv是不確定的」。在檢查螢火蟲時,this._headerDiv
的範圍是Window而不是父窗口小部件。
請幫我理解我在這裏錯過了什麼。
我覺得你需要在'dojo.hitch'中包裝'onEnd'回調函數。 – Lucas
你是對的。謝謝。 –
對不起。此解決方案不適合我。 – Divij