对不起,这个愚蠢的问题。如何在 javascript switch-case 语言元素中为 case 使用条件?像下面的例子一样,当变量liCount
<=5 和 >0时,case 应该匹配;但是,我的代码不起作用:
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;
}
感谢您的任何建议!