小程序navigatorTo缺點和修正方法


1.不好帶參數跳轉到tabbar,即下部的導航欄目。

  reLauntch方法可以傳遞參數到導航欄目;

  

    go_to_prolist: function (e) {
        var datatype = e.currentTarget.dataset.datatype;
        wx.reLaunch({
            url: '../product/product?datatype=' + datatype,
        });
        /*
        wx.navigateTo({
            url:'../product/prolist?datatype='+datatype,
        });
        */
    },

 

 

 

2.循環點擊(最多3 4次),會使得bindtap按鈕消失;

附錄(什么是循環點擊,從A to B的bindtap,再從B to A,如此循環);

  用redirect方法,可以修復這個缺點~~~~

  go_to_mycoupon:function(e){
    var that = this;
    var order_num = e.currentTarget.dataset.order_num;//未必整型
    var product_id = e.currentTarget.dataset.product_id;
    wx.redirectTo({
      url: '/pages/coupon/my_coupon?order_num=' + order_num + '&product_id=' + product_id,
    })
  },

  

  • navigateTo,redirectTo只能打開非 tabBar 頁面。
  • switchTab 只能打開 tabBar 頁面。
  • reLaunch 可以打開任意頁面。
  • 頁面底部的 tabBar 由頁面決定,即只要是定義為 tabBar 的頁面,底部都有 tabBar。
  • 調用頁面路由帶的參數可以在目標頁面的onLoad中獲取。

onShow  傳遞不了參數

 


免責聲明!

本站轉載的文章為個人學習借鑒使用,本站對版權不負任何法律責任。如果侵犯了您的隱私權益,請聯系本站郵箱yoyou2525@163.com刪除。



 
粵ICP備18138465號   © 2018-2025 CODEPRJ.COM