Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

跳转以后如何还能获取之前的数据 #23

Open
lovelmh13 opened this issue Mar 15, 2020 · 0 comments
Open

跳转以后如何还能获取之前的数据 #23

lovelmh13 opened this issue Mar 15, 2020 · 0 comments

Comments

@lovelmh13
Copy link
Owner

背景

我当前页面里有一些参数,现在需要某些原因跳到别的页面再回来,比如第三方登录,登陆成功再重定向回来。我回来以后数据就没有了

方法

如果还想保留住那些数据,前提是数据不敏感,可以加到当前的url里面,类似url?xxx=yyy这种。因为第三方登陆,有redirect_uri这个重定向回来的路径参数,那么我们就可以把当前的url,加上我们需要的参数,传给redirect_uri,我们跳回来的时候,就依然可以拿到跳转前的值了

伪代码

let redirectUrl = window.location.href + '&type=' + type + '&cb=' + ctime;
redirectUrl = encodeURIComponent(redirectUrl)

url = "https://graph.qq.com/oauth2.0/authorize?response_type=code&client_id=" + appId + "&redirect_uri=" + redirectUrl
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant