我在 JavaScript 中使用循环嵌套开关,例如:
for (var i = 0; i < checkBoxIds.length; i++) {
if ($('#' + checkBoxIds[i]).prop('checked')) {
var id = checkBoxIds[i];
var assetCat = id.substring(0, 4);
switch (id.substring(id.length - 3)) {
case "scr":
if (!sscripts)
if (confirm("Name of scripts sub-folder (in shared) is not provided for " + assetCat + ". Press OK to Continue for others?"))
continue; else break; //else return
//Appending chrs or sets or props to scripts
switchAssets(sscripts, IdEnum.SCRIPTS);
break;
case "shd":
if (!sshaders)
if (confirm("Name of shaders sub-folder (in shared) is not provided for " + assetCat + ". Press OK to Continue for others?"))
continue; else break; //else return
//Appending chrs or sets or props to shaders
switchAssets(sshaders, IdEnum.SHADERS);
break;
case "sim":
if (!ssourceimages)
if (confirm("Name of sourceimages sub-folder (in shared) is not provided for " + assetCat + ". Press OK to Continue for others?"))
continue; else break; //else return
//Appending chrs or sets or props to sourceimages
switchAssets(ssourceimages, IdEnum.SOURCEIMAGES);
break;
default:
}
}
}
//...Still doing something (else return; will never kiss this :D )
}
如果!sscripts是假的,我问用户是否要继续其他复选框,如果他取消,我想打破循环并在函数中执行剩余的语句。好像休息;在执行 switch 的确认对话框中,我怎样才能让它运行 for-loop。
任何建议将不胜感激。