vue项目中微信登录的实现
程序员文章站
2022-03-12 19:25:11
引组件 wxlogin给组件传参重定向的url应该是微信登录官网中的微信授权作用域如果url里面有端口号,微信授权作用里面也要有重定向的url:需要在http://tool.chinaz.com/tools/urlencode.aspx中转码微信登录成功后,会自动重定向到新地址,此时的地址栏中就有code参数如果报错说不能从组件跳到页面,那就找到wxlogin组件里面的iframe标签,加上这个属性:sandbox=“allow-scripts allow-top-navigation all....
- 引组件 wxlogin
- 给组件传参
- 重定向的url应该是微信登录官网中的微信授权作用域
- 如果url里面有端口号,微信授权作用里面也要有
- 重定向的url:需要在http://tool.chinaz.com/tools/urlencode.aspx中转码
- 微信登录成功后,会自动重定向到新地址,此时的地址栏中就有code参数
- 如果报错说不能从组件跳到页面,那就找到wxlogin组件里面的iframe标签,加上这个属性:sandbox=“allow-scripts allow-top-navigation allow-same-origin”
报错内容:
qrconnect?scope=snsapi_login&redirect_uri=http%3a%2f%2f%2f&state=&login_type=jssdk&self_redirect=false&style=black&href=:84 Unsafe JavaScript attempt to initiate navigation
for frame with origin 'http://localhost:9020' from frame with URL
'https://open.weixin.qq.com/connect/qrconnect?app&scope=snsapi_login&redirect_uri=http%3a%2f%2f&state=&login_type=jssdk&self_redirect=false&style=black&href='.
The frame attempting navigation is targeting its top-level window, but is neither same-origin with its target nor has it received a user gesture.
See https://www.chromestatus.com/features/5851021045661696.```
本文地址:https://blog.csdn.net/my_web_advanced/article/details/107471172