问题
uni-app开发微信回调的时候 不支持url 上面带有 ‘’#‘’的地址如:/#/pages/demo/wxlogin
解决方案
配置 history
模式
此处使用IIS来演示
- 安装 IIS UrlRewrite
- 在网站的根目录下创建一个
web.config
文件,内容如下:
<?xml version="1.0" encoding="UTF-8"?>
<configuration>
<system.webServer>
<rewrite>
<rules>
<rule name="Handle History Mode and custom 404/500" stopProcessing="true">
<match url="(.*)" />
<conditions logicalGrouping="MatchAll">
<add input="{REQUEST_FILENAME}" matchType="IsFile" negate="true" />
<add input="{REQUEST_FILENAME}" matchType="IsDirectory" negate="true" />
</conditions>
<action type="Rewrite" url="/" />
</rule>
</rules>
</rewrite>
</system.webServer>
</configuration>
参考链接
https://router.vuejs.org/zh/guide/essentials/history-mode.html#后端配置例子
https://uniapp.dcloud.io/collocation/manifest?id=h5-router