微信公众号授权登录获取code
login页面中的关键授权代码:
onMounted(() => {
const code = route.query.code;
if (code) {
localStorage.setItem("code", code);
} else {
startSilentAuth();
}
});
const startSilentAuth = () => {
const appId = "wxappid";
let authPath = "https://test.xxx.com/login"
const redirectUri = encodeURIComponent(authPath);
const authUrl = `https://open.weixin.qq.com/connect/oauth2/authorize?appid=${appId}&redirect_uri=${redirectUri}&response_type=code&scope=snsapi_base&state=123#wechat_redirect`;
window.location.replace(authUrl);
};
目前的问题是在微信浏览器中
未授权初次进入页面是https://test.xxx.com/login
授权后返回页面是https://test.xxx.com/login?code=xxxxxx
在微信浏览器中会出现前进、后退按钮,路由堆栈出现了两条记录(都是login页面)
如何使微信浏览器路由堆栈只有一条记录,不让出现前进后退按钮?
同问,这个问题太恶心了,谁有解决办法的,关键点击ios上的返回,监听不到