猿问

switch case

在js文件中使用switch case语句不起作用,改为if else就好使了,什么原因?

var option;

/* switch(obj._printSelectedOption){

case 1:

case 8:

option = "_navi";

break;

case 2:

case 7:

option = "_navi_dis";

break;

case 4:

case 5:

option = "_dis";

break;

case 10:

case 14:

option = "_dcl";

break;

case 11:

case 16:

option = "_dcl_dis";

break;

case 12:

case 15:

option = "_navi_dcl";

break;

case 13:

case 17:

option = "_navi_dcl_dis";

break;

default:

option = "";

break;

}*/

if(obj._printSelectedOption ==1 ||obj._printSelectedOption ==8){

option = "_navi";

}else if(obj._printSelectedOption ==2 ||obj._printSelectedOption ==7){

option = "_navi_dis";

}else if(obj._printSelectedOption ==4 ||obj._printSelectedOption ==5){

option = "_dis";

}else if(obj._printSelectedOption ==10 ||obj._printSelectedOption ==14){

option = "_dcl";

}else if(obj._printSelectedOption ==11 ||obj._printSelectedOption ==16){

option = "_dcl_dis";

}else if(obj._printSelectedOption ==12 ||obj._printSelectedOption ==15){

option = "_navi_dcl";

}else if(obj._printSelectedOption ==13 ||obj._printSelectedOption ==17){

option = "_navi_dcl_dis";

}else{

option = "";

}


瑞若晨曦
浏览 1104回答 1
1回答
随时随地看视频慕课网APP

相关分类

JavaScript
我要回答