注意:此方法僅爲我的總結,並不是惟一解決方案
vue路由模式 history 模式,有兩點好處html
微信官方說明以下前端
全部須要使用JS-SDK的頁面必須先注入配置信息,不然將沒法調用(同一個url僅需調用一次,對於變化url的SPA的web app可在每次url變化時進行調用,目前Android微信客戶端不支持pushState的H5新特性,因此使用pushState來實現web app的頁面會致使簽名失敗,此問題會在Android6.2中修復)由此可知,對於vue等SPA應用,Android和IOS 要作不一樣的處理了vue
通過反覆測試實驗,發現如下問題nginx
至此,解決方案已經出爐git
問題描述github
- 微信支付目錄要求最多配置5個目錄
- 支付目錄 必須細分到二級或以上
支付目錄配置規則示例web
你的支付目錄以下: 例1:http://pandao.github.io/show/base - 支付配置:http://pandao.github.io/show 例2:http://pandao.github.io/pay/show?a=2&b=3 - 支付配置 http://pandao.github.io/pay/
解決方案vue-router
問題描述後端
vue history模式,須要配合後端服務器配置才能生效
相應的配置示例服務器
Apache
<IfModule mod_rewrite.c> RewriteEngine On RewriteBase / RewriteRule ^index\.html$ - [L] RewriteCond %{REQUEST_FILENAME} !-f RewriteCond %{REQUEST_FILENAME} !-d RewriteRule . /index.html [L] </IfModule>
Nginx
location / { try_files $uri $uri/ /index.html; }
我採用的nginx的配置
因此個人配置爲
location ^~ /weixin/ { try_files $uri $uri/ /index.html; }
前言鋪墊夠多了,下面說說 受權回調的解決方案