Prospects for review

We developed a third-party mobile wechat application project, which needed to jump into the enterprise wechat. After the route jump, we closed the built-in browser of wechat after the last route according to the back key on the mobile phone (or sliding left and right).

However, the third-party H5 project directly jumped to the page after obtaining the authorization of wechat. I hid and simulated a login route, obtained the token first and then followed up the route related to the jump. When I used the return key of the mobile phone, the last route was login. It was impossible to directly close the wechat built-in browser and a blank page appeared, which was solved after a lot of exploration.

The solution

  1. Install the SDK of wechat

Yarn add weixin-js-sdk –save the plug-in can be installed according to the NPM or YARN

  1. Reference wechat SDK

import wx from 'weixin-js-sdk'

  1. Close the wechat browser

// Add the following line of code wx.closeWindow() where necessary

conclusion

Follow the above steps where necessarywx.closeWindow()When this line of code can be closed wechat built-in browser.

extension

The plug-in can be directly introduced into wechat API, can be directly operated, can be applicable toWeChat public.Small program.Enterprise wechat applicationAnd so on.

Reference documentation

  • Blog.csdn.net/m0_37508531…
  • Development of wechat public account — use of wechat JSSDK (stomp pit)
  • Weixin – js – SDK NPM address