const app = getApp(); Page({ data:{ statusBarHeight:20, current:0, show:[1], list:[ {text:"课堂", type:"course"}, {text:"实训", type:"shixun"}, //{text:"课程"} ] }, onLoad(){ wx.getSystemInfo({ success: res=>{ let {statusBarHeight} = res; this.setData({statusBarHeight}); }, }) }, enterSearch(){ let type = this.data.list[this.data.current].type||''; app.navigateTo({url:`{search}?type=${type}`}); }, switchNav({target:{dataset:{current}}}){ this.setData({current}); this.setData({['show['+current+']']:1}) }, switchTab({detail:{current, source, value}}){ console.log(current, source, value); if(source=="touch"){ this.setData({ current }); this.setData({ ['show[' + current + ']']: 1 }) } }, onShareAppMessage(){ } })