欧美bbbwbbbw肥妇,免费乱码人妻系列日韩,一级黄片

微信小程序 空白頁(yè)重定向解決辦法

 更新時(shí)間:2017年06月27日 14:40:39   投稿:lqh  
這篇文章主要介紹了微信小程序 空白頁(yè)重定向解決辦法的相關(guān)資料,需要的朋友可以參考下

微信小程序 空白頁(yè)重定向解決辦法

 在剛開(kāi)始的時(shí)候?qū)⑿〕绦虻娜肟谖募苯又赶騮abbar 的首頁(yè),此時(shí)出現(xiàn)問(wèn)題:二維碼掃描,第一次不關(guān)閉首頁(yè),第二次進(jìn)入時(shí);不會(huì)經(jīng)過(guò)onLoad過(guò)程解析scene參數(shù);

官方中解釋:tabbar跳轉(zhuǎn)方式觸發(fā)的生命周期是 onShow,不經(jīng)過(guò)onLoad,下圖:

此時(shí),和小伙伴討論重定向問(wèn)題時(shí),想到用類(lèi)似的方法可以做到,就立馬實(shí)行:

  app.json中加pages/index/index(入口文件),pages/home/home(tabbar頁(yè)面主頁(yè)),pages/detail/detail(詳情頁(yè));pages/exclusive/exclusive

在index.js中 onLoad處理:

/**
  * 生命周期函數(shù)--監(jiān)聽(tīng)頁(yè)面加載
  */
 onLoad: function (options) {
  // 入口文件 決定進(jìn)入哪個(gè)頁(yè)面
  console.log('入口文件,參數(shù)scene,值detail%2C1127')
  var scene = options.scene; //掃碼進(jìn)入有此參數(shù)
  var scene = decodeURIComponent(options.scene);
  if (scene) {
   //'scene=detail%2C1127' 分隔符, 測(cè)試時(shí)為 , 號(hào);真機(jī)時(shí)為%2C 原因是url編碼,但是使用decodeURI()解析不出來(lái),所以走了兼容
   
   let info_arr = [];
   info_arr = scene.split(',');
   //console.log(info_arr)
   let _type = info_arr[0];
   let id = info_arr[1];
   if (_type == 'detail') {
    wx.redirectTo({ url: `../detail/detail?id=${id}`, })
   } else if (_type == 'exclusive') {
    wx.redirectTo({ url: `../exclusive/exclusive?id=${id}`, })
   }
  }else{
   wx.switchTab({
    url: '../home/home',
   })
  }
 },

此時(shí),完美解決 從 掃碼-->home-->detail;再次掃碼-->home 不能到-->detail的問(wèn)題;

此時(shí) 掃碼-->index(redirectTo)-->detail;再次掃碼-->index(redirectTo)-->detail的問(wèn)題;越過(guò)home頁(yè)面

由于home頁(yè)面有大量的請(qǐng)求,不適宜用redirectTo;所以此方法算是折中的選擇了

感謝閱讀,希望能幫助到大家,謝謝大家對(duì)本站的支持!

相關(guān)文章

最新評(píng)論