- 第一步,首先去windows里的host文件设置代理比如你本地就设置为120.0.0.1 test.vue.com
- 第二步,开启vue的devSever里的
disableHostCheck:false,port:80 - 第三部填写相应的代码
let local = encodeURIComponent(window.location.origin); // 对url进行编码
let urloo = `https://open.weixin.qq.com/connect/oauth2/authorize?appid=你的appid&redirect_uri=${local}&response_type=code&scope=snsapi_userinfo&state=123#wechat_redirect`;
window.location.href = urloo;
总结:端口号必须80,不然8080这种微信不认,然后你跳转后的连接会有code等关键字,就可以通过他去授权了。 最后你的链接应该长这样 test.vue.com/#/login
不懂欢迎评论