WeChat applet global routing interception

foreword

slightly

WeChat applet global routing interception method 1

Currently, there is no global routing interception for WeChat applets. To achieve global routing interception, you need to expand it yourself. For details, refer to here: WeChat Mini Program – Routing Interceptor .

Implementation idea:

  1. Replace the onShow or onLoad method of the Page's parameter object.
  2. Determine whether you have logged in in the replaced onShow or onLoad method.
  3. Pass the replaced parameter object to Page.

WeChat applet global routing interception method 2

Implementation idea:

  1. wx.redirectToReplace , wx.switchTab, wx.reLaunch, wx.navigateTo, with the new method wx.navigateBack.
  2. In the new method, determine whether you have logged in.
  3. wx.redirectToWhere the , wx.switchTab, wx.reLaunch, wx.navigateTo, wx.navigateBackmethods need to be called , call the new method instead.

reference

WeChat applet – routing interceptor
WeChat applet global routing interception
WeChat applet is similar to middleware for routing interception

Guess you like

Origin blog.csdn.net/sayyy/article/details/130686718