[英]Jslint settimeout used before defined
var AnimationManager = function (time, completionMethod) {
"use strict";
this.animationObjects = [];
this.time = time;
this.add = function (animationObject) {
this.animationObjects.push(animationObject);
};
this.completionMethod = completionMethod;
this.currentStage = 0;
this.maximumStage = this.time * FPS;
this.tick = function () {
this.currentStage += 1;
if (this.currentStage < this.maximumStage) {
setTimeout(this.tick.bind(this), 1000.0 / FPS);
} else {
//Set manager to nil in the completion method
this.completionMethod();
}
var i;
for (i = 0; i < this.animationObjects.length; i += 1) {
this.animationObjects[i].applyAnimation(this.currentStage);
}
};
//Call this to start
this.startAnimation = function () {
this.timer = setTimeout(this.tick.bind(this), 1000.0 / FPS);
};
};
括號中的JSLint給了我一些煩人的錯誤; 'setTimeout' was used before it was defined. setTimeout(this.tick.bind(this), 1000.0 / FPS);
兩個類似的命令: 'setTimeout' was used before it was defined. setTimeout(this.tick.bind(this), 1000.0 / FPS);
'setTimeout' was used before it was defined. setTimeout(this.tick.bind(this), 1000.0 / FPS);
這到底是在說什么!
它還使用console.log來做到這一點。console是未定義的。
您必須告訴JSLint您的代碼在瀏覽器中運行,並且還需要假定已定義console
。
將其放在您的代碼之上:
/*jslint browser: true, devel: true */
老實說,我更喜歡JSHint這是少opiniated。
聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.