我使用的是React框架.当我以 loginRedirect()
方法,我又被重定向到我提供的重定向URLI --------------。https:localhost:3000
.
在重定向后(回到我的页面),当 componentDidMount()
被称为。msalInstance.getAccount()
返回null,因为token还没有被创建。在这之后,重定向回调被触发。
componentDidMount()
因此,我必须在重定向后重新加载页面,这样才能让我的网站更有价值。msalInstance.getAccount()
内有 componentDidMount()
工作.如何处理这种情况?
你得到的是空值,因为你没有等待你的响应。试着在 componentDidMount() 中使用 Promises 或 asyncawait。
这个问题是@azuremsal-browser的v2.0.0-beta版本的问题,后来在下一个版本-v2.0.0-beta.1中得到了解决。