JavaScript:在 switch case 中使用条件
2022-08-30 05:03:51
如何在 JavaScript 的 switch 语句中使用条件?在下面的示例中,当变量为 和 时,事例应匹配;但是,我的代码不起作用:liCount
<= 5
> 0
switch (liCount) {
case 0:
setLayoutState("start");
var api = $("#UploadList").data("jsp");
api.reinitialise();
break;
case liCount <= 5 && liCount > 0:
setLayoutState("upload1Row");
var api = $("#UploadList").data("jsp");
api.reinitialise();
break;
case liCount <= 10 && liCount > 5:
setLayoutState("upload2Rows");
var api = $("#UploadList").data("jsp");
api.reinitialise();
break;
case liCount > 10:
var api = $("#UploadList").data("jsp");
api.reinitialise();
break;
default:
break;
}
感谢您的任何建议!