【问题标题】:How to redirect after success from ajax call using React?如何使用 React 从 ajax 调用成功后重定向?
【发布时间】:2016-03-30 14:51:56
【问题描述】:

我是使用 ReactJS 的新手,我想知道如何在没有 react-route 或 Flux 的情况下使用 React 从 ajax 调用成功后重定向? 那可能吗 ?有人可以帮我吗

【问题讨论】:

    标签: javascript json web-services rest reactjs


    【解决方案1】:

    您可以在 ajax 回调中更改 window.location.href 以将浏览器重定向到新的 url。

    【讨论】:

      【解决方案2】:

      我在 React 和 React-routes 上玩的不多。但是你可以使用 JS 版本。

      // similar behavior as an HTTP redirect 
      window.location.replace("http://stackoverflow.com"); 
      
      // similar behavior as clicking on a link 
      window.location.href = "http://stackoverflow.com";
      

      来源LINK

      【讨论】:

        猜你喜欢
        • 2015-04-11
        • 1970-01-01
        • 1970-01-01
        • 1970-01-01
        • 1970-01-01
        • 1970-01-01
        • 2014-10-25
        • 2021-02-14
        • 2020-07-18
        相关资源
        最近更新 更多