.defer(5000)
在JavaScript中導致too much recursion
錯誤。我如何延遲執行5秒?如何在JavaScript中延遲
rotate: function() {
if (!paused) {
this.show(counter);
counter = counter + 1;
if (counter === Spire.Rotator.data.items.length) {
counter = 0;
}
Spire.Rotator.rotate().defer(5000);
//$.proxy(Spire.Rotator.rotate, Spire.Rotator).defer(delay);
}
}
不要使用字符串作爲setTimeout的參數。這是有效的,但容易引用地獄,也很慢。改用一個函數:'setTimeout(Spire.Rotator.rotate,5000)' – slebetman 2010-11-19 03:20:04
@slebetman啊!當然是。感謝您的提醒。 :) – Alex 2010-11-19 03:21:35