<!doctype html> <html lang="en"> <head> <meta charset="UTF-8"> <title>Document</title> </head> <body> <script> let a = '2'; switch (a) { case 1: console.log(1); break; case 2: console.log(2); break; case 3: console.log(3); break; case 4: console.log(4); break; default: console.log('没有匹配的') } </script> </body> </html>
switch做判断的时候用的是===而不是==
猜你喜欢
转载自www.cnblogs.com/ustc-yy/p/12072836.html
今日推荐
周排行