繁体   English   中英

反应在 window.location 上返回 null

[英]React returning null on window.location

我正在尝试使用 discord.js oauth,为此我需要能够获取 oauthpage.location.hash,但是当我尝试记录 oauthpage.location 时,它返回一个空的位置对象: Location {ancestorOrigins: DOMStringList, href: 'about:blank', origin: 'null', protocol: 'about:', host: '', …} 有谁知道如何解决这一问题?

const oauthpage = window.open(url, "_blank", "height=1000,width=500")
console.log(oauthpage?.location)

Note that remote URLs won't load immediately. When window.open() returns, the window always contains about:blank. The actual fetching of the URL is deferred and starts after the current script block finishes executing. The window creation and the loading of the referenced resource are done asynchronously.

https://developer.mozilla.org/en-US/docs/Web/API/Window/open https://discordjs.guide/oauth2/#implicit-grant-flow - 见window.onload

暂无
暂无

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM