我正在尝试制作一个在上传视频时停止的不定式循环。该功能工作正常,但是停止循环似乎不起作用。我得到的错误是:
clearImmediate 未定义
这是我想要做的循环:
window.setImmediate = window.setTimeout; //had to add this for it to start the loop
var videoIsUploaded = false;
var immediateId;
function loop() {
console.log('still uploading');
immediateId = setImmediate(loop);
if (videoIsUploaded == true) {
window.clearImmediate(immediateId);
HideTheUpload();
}
}
loop();
function HideTheUpload(){
document.getElementById("AddVideo").style.display = "none";
}
Azure 上传视频后,它会设置“videoIsUploaded = true”,这一切正常,“if (videoIsUploaded ...”会触发