1、问题: HashRouter分享到朋友圈出现的问题
在 Vue
、React
等单页面应用中采用了 HashRouter
路由时,分享到 QQ
、微信
、朋友圈
时,腾讯会在 index.html
后,#
前追加相关参数。
示例https://*****/index.html#/share?paramsA=**¶msB=**
,若在单页面应用中分享出这样的链接。分享到 朋友圈
时,链接地址变为:https://*****/index.html?from=groupmessage#/share
导致打开页面出现 404
错误。
解决
在分享的链接地址后追加 ?&
字符,将腾讯追加的参数放到链接最后。即:
https://*****/index.html#/share?paramsA=**¶msB=**?&
分享的链接
https://*****/index.html#/share?paramsA=**¶msB=**?from=groupmessage
分享后的链接