window.open被拦截解决方案

打开一个空白页面,将url window.location.href = url;
如果一旦url没有回调获取到,而打开一个空白页面,会让人很诧异。比较好的方案就是我们去监听是否拿到了url, 一旦拿到了,我们就window.open(url).
具体实现:

setInterval(() => {
if ( this.useRef.current) {
window.open(this.useRef.current)
}
}, 100)

请求promise.then(res=> this.useRef.current = res);

你可能感兴趣的:(javascript)