先將 鏈接拼接編譯
scope為snsapi_userinfo
https://open.weixin.qq.com/connect/oauth2/authorize?appid=wxf0e81c3bee622d60&redirect_uri=http%3A%2F%2Fnba.bluewebgame.com%2Foauth_response.php&response_type=code&scope=snsapi_userinfo&state=STATE#wechat_redirect
<body> <a onclick="dianji()">點擊</a> </body> </html> <script src="Scripts/jquery-3.4.1.min.js"></script> <script> //點擊調用此方法 function dianji() { //拼接跳轉鏈接 var dz = "https://open.weixin.qq.com/connect/oauth2/authorize?appid=wxf0e81c3bee622d60&redirect_uri="; //編譯Url var REDIRECT_URI = encodeURIComponent("http://nba.bluewebgame.com"); var dzq="&response_type=code&scope=snsapi_userinfo&state=STATE#wechat_redirect" //拼接后的鏈接 var url = dz + REDIRECT_URI + dzq; //跳轉此鏈接 } </script>
編寫后 將此代碼用瀏覽器 並使用F12鍵 將url的值輸出出來 將輸出后的鏈接使用 微信WEB開發者工具打開 運行此鏈接后得到下圖展現的效果 授權獲取COde則獲取成功