javascript - 提交后需要重定向到上一页

标签 javascript reactjs

我需要在提交表单后重定向到 premontessori 页面。我该怎么做?

这是我的handleSubmit 函数:

handleSubmit(event) {
     event.preventDefault();
     <Link to='/premontessori' style={{textDecoration:'none'}} > alert("New Student Created");</Link>
     var data= {
           Fname:this.state.Fname,
           age:this.state.age,
           Lname:this.state.Lname,
           dob:this.state.dob,
           pob:this.state.pob,
           month:this.state.month,
           nation:this.state.nation,
           mothertongue:this.state.mothertongue,
           bloodgroup:this.state.bloodgroup
      };
      axios.post('/create',data)
        .then(function(response){
        console.log(response);
      })
}

最佳答案

您可以使用 react 路由器(例如-hashHistory)进行导航。

hashHistory.goBack();

关于javascript - 提交后需要重定向到上一页,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/42270459/

相关文章:

javascript - Google 标记动画更改

C# 单选按钮 oncheckchanged 未触发

javascript - 固定页脚的最小高度 - 我使用@media

javascript - 如何在客户端使用 JavaScript 运行 Linux 命令

javascript - 如何在不使用 JSX 的情况下在 React Native 中制作组件?

javascript - 将外部文本从 .txt 加载到 html 文件

javascript - 使用 API 分页

node.js - PUBG 移动 api - 是否存在任何返回用户信息的 pubg 移动 api

javascript - JS/React 的类似 ViewDidAppear 的方法?

javascript - 为什么在 componentDidUpdate 中比较数组不会导致无限循环?