Question:
Recently, there was a problem when I did wechat H5: IOS wechat wx.config failed, Android succeeded.
Phenomenon:
Android and IOS get signature parameters, exactly the same
After testing, I found a magical phenomenon: when I opened the page for the first time in ios, the config failed, but I clicked the refresh button of wechat to refresh the page, and the page config succeeded!!
Because I this H5 is through the authorized link jump over, so guess: with this jump process, so Baidu ~
Sure enough, it is found that the performance of wechat embedded browser is different between iOS and Android: in Android, the URL required for signature is the URL of the current page, but in iOS, wechat needs the entry URL instead of the URL of the current page. For details, please refer to the solution of wechat JSSDK signature error invalid Signature
Therefore, if the H5 page is not redirected through authorization, but directly opens the link of H5 itself, because there is no page redirected, the entry URL= current page URL, the config can be successful.
Try to solve:
Due to this authorization has an effect on the business, can’t take out, so the original poster to authorize link to obtain the signature (is before the window. The location. The href. Split (‘ # ‘) [0]), the result still failed…
Final solution:
If there is no refresh parameter in the url, I will refresh the page and add the refresh parameter to it. After refreshing the page, it will be a simple ordinary H5 page with no jump, and then I can configure it successfully. I don’t do it
The timing of the refresh is arbitrary, and the beforeCreate/created callback should also work, as well as inserting the code directly at the top of the body tag. This is vUE, and the same thing happens if you do React