【问题标题】:window.location.href not redirecting to external url inside await methodwindow.location.href 未重定向到 await 方法内的外部 url
【发布时间】:2022-11-15 14:41:15
【问题描述】:

我有如下功能

const redirect = async ()  => {
    await aFunc().then(async () => {
        await bFunc().then((externalUrl) = {
            window.location.href = externalUrl;
        });
    });
}
await redirect();

当我调试这段代码时,我注意到当它执行“window.location.href”行时,它不会重定向到外部 url,而是重新加载它自己的页面

【问题讨论】:

    标签: javascript


    【解决方案1】:

    改变

    window.location.href = externalUrl;

    window.location = externalUrl;

    【讨论】:

      猜你喜欢
      • 2019-04-03
      • 1970-01-01
      • 2017-12-11
      • 2012-01-10
      • 2012-08-02
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      相关资源
      最近更新 更多