history.push 不重定向到外部 URL

问题描述 投票:0回答:0

我有一个在点击按钮时运行的函数。我想将用户定向到外部站点。我似乎无法使用 history.push 来完成它,因为它将站点附加到 localholst 即 http://localhost:8080/EXTERNALSITE

我正在使用 RR v5

下面的代码有效,但我如何使用 React 路由器?

  const handleButtonClick = () => {
    if (foo) {
      window.location.replace(EXTERNALSITE); // how to use RR here?
    } else if (userToken) {
      history.push('/home');
    } else {
      logout();
    }
  };
reactjs react-router react-router-dom
© www.soinside.com 2019 - 2024. All rights reserved.