我可以在switch语句中使用间隔吗?
喜欢
switch (parseInt(troops[i])) { case <10: edit@R_301_460@.style.fontSize = "13px"; break; case <100: edit@R_301_460@.style.fontSize = "12px"; break; case <1000: edit@R_301_460@.style.fontSize = "8px"; edit@R_301_460@.size = 3; //edit@R_301_460@.style.width = "18px"; break; default: edit@R_301_460@.style.fontSize = "10px"; }
???
解决方法
这应该工作:
var j = parseInt(troops[i]); switch (true) { case (j<10): edit@R_301_460@.style.fontSize = "13px"; break; case (j<100): edit@R_301_460@.style.fontSize = "12px"; break; case (j<1000): edit@R_301_460@.style.fontSize = "8px"; edit@R_301_460@.size = 3; //edit@R_301_460@.style.width = "18px"; break; default: edit@R_301_460@.style.fontSize = "10px"; }