在小程序中使用了tabBar組件之后就不能用wx.navigateTo跳轉(zhuǎn)到tabBar頁(yè)面了 , 能跳轉(zhuǎn)到tabBar頁(yè)面的方法有以下兩種
?文章來(lái)源:http://www.zghlxwxcb.cn/news/detail-507700.html
但是使用第一種方法時(shí),會(huì)因?yàn)檫@種方法在路徑后不能攜帶參數(shù),所以行不通
那么就只能用第二種方法 , 用wx.reLaunch進(jìn)行跳轉(zhuǎn) , 地址后跟上自己想要的參數(shù) , 或者用wx.setStorage將想要的參數(shù)存到內(nèi)存中去 , 在下個(gè)頁(yè)面中直接用wx.getStroge去內(nèi)存中取出
?getInfo(){
? ? let that = this;
? ? wx.request({
? ? ? url: this.data.baseURL+'/user/info?token='+this.data.token,
? ? ? success (res) {
? ? ? ? that.setData({
? ? ? ? ? ? info:userinfo
? ? ? ? })
? ? ? ? wx.setStorage({
? ? ? ? ? data: res.data.data.id,
? ? ? ? ? key: 'id',
? ? ? ? })
? ? ? ? wx.setStorage({
? ? ? ? ? data: res.data.data.name,
? ? ? ? ? key: 'name',
? ? ? ? })
? ? ? ? wx.setStorage({
? ? ? ? ? data: res.data.data.avatar,
? ? ? ? ? key: 'avatar',
? ? ? ? })
? ? ? ? // 用了tabBar之后,不能用wx.navigateTo
? ? ? ? wx.reLaunch({
? ? ? ? ? url:'../user/user?userinfo='+that.data.info
? ? ? ? })
? ? ? }
? ? })
? },
取出的方法也放在這里
?
let that = this;
? ? wx.getStorage({
? ? ? key: 'id',
? ? ? success:function(r){
? ? ? ? console.log(r.data)
? ? ? ? that.setData({
? ? ? ? ? id:r.data,
? ? ? ? })
? ? ? }
? ? })
這樣就能把數(shù)據(jù)存放到該頁(yè)面的data:{}中對(duì)應(yīng)的屬性里 , 至于這里為什么要用that,關(guān)于this指向問(wèn)題,讀者可以自行搜索學(xué)習(xí)。文章來(lái)源地址http://www.zghlxwxcb.cn/news/detail-507700.html
到了這里,關(guān)于微信小程序中如何攜帶參數(shù)跳轉(zhuǎn)到tabBar頁(yè)面的文章就介紹完了。如果您還想了解更多內(nèi)容,請(qǐng)?jiān)谟疑辖撬阉鱐OY模板網(wǎng)以前的文章或繼續(xù)瀏覽下面的相關(guān)文章,希望大家以后多多支持TOY模板網(wǎng)!