微信小程序判断语句怎么样正确执行?switch语句怎样正确执行?
新手,判断语句无法正确执行,百度了老半天
代码片段 https://developers.weixin.qq.com/s/1fIzyBmt7Mex
js:
const app = getApp()
Page({
data: {
},
onLoad: function () {},
onclick: function(e) {
var id = e.target.id;
//console.log(e)
//console.log(id)
switch (id) {
case 0: console.log("按键1");
case 1: { debugger;console.log("按键2") };
case 2: { console.log("按键3") };
}
/* if (id == 0) {
console.log(id)
} else if (id == 1) { console.log("按键2")}
else { console.log("按键3")}
*/ }})