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:
- Replace the onShow or onLoad method of the Page's parameter object.
- Determine whether you have logged in in the replaced onShow or onLoad method.
- Pass the replaced parameter object to Page.
WeChat applet global routing interception method 2
Implementation idea:
wx.redirectTo
Replace ,wx.switchTab
,wx.reLaunch
,wx.navigateTo
, with the new methodwx.navigateBack
.- In the new method, determine whether you have logged in.
wx.redirectTo
Where the ,wx.switchTab
,wx.reLaunch
,wx.navigateTo
,wx.navigateBack
methods 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