Recently, I used VUE to make a wechat official account project, and encountered some problems in authorization and sharing. Here is a record.
When using hash mode, there is no problem with ios and Android sharing (no error will be reported if the current URL signature is passed in), but there is a drawback of hash mode. There will be a # symbol in the link, and the front-end page authorization needs to pass in the current page URL, but this URL is forbidden on wechat. Symbols other than and &, so hash mode is not recommended.
However, there is no problem with authorizing login when using the History mode, but there will be an error when sharing the signature in ios. After consulting the data, WE know that the implementation of vue’s History mode is a little different between ios and Android. In Android, normal page jump is simulated during route conversion. In ios, it is only written in the jump history, which cannot simulate the normal page jump. However, when wechat shares the signature, it must pass in the current page URL. As a result, the history mode can be shared normally in Android, while in ios, it can be shared except on the first page entered, but cannot be shared on the page after the route change.
The solution to history: only need to distinguish ios and Android each time to share the URL to obtain the signature, you can directly determine whether ios terminal when loading into the page, and then save the current URL into the cache, each time to share using this URL can be normal sharing.
Ps: Finally, there is a small hole, I wrote in app. vue to judge the terminal logic, and if there is a redirection in the route configuration, then the link entered for the first time does not, and then the redirection, ios can not share, this preliminary judgment should be vue’s route redirection execution logic problem. I have no time to solve it for the time being. I told the product that only normal routing connections would be exposed to the outside. Ha ha, there is no way.