美文网首页
React + Ts 番茄钟总结

React + Ts 番茄钟总结

作者: Grit0821 | 来源:发表于2019-07-19 17:21 被阅读0次
  1. 单页应用,根组件注入store使用react redux进行状态管理,包括对任务列表和番茄时钟列表的管理,基本实质就是发送请求修改后端数据后,对state进行更改。
  2. 登录注册页面,输入用户名和密码后,axios拦截响应把响应头的x-token放到localStorage里,下次访问时x-token放在请求头里。
  3. 路由实现和跳转,react router跳转的两种方式类似vue router的声明式导航和编程式导航,<Router >里面传入属性history为了实现编程式导航
<Router history={history}>
   <div>
     <Route exact={true} path="/" component={Home} />
     <Route path="/login" component={Login} />
     <Route path="/signUp" component={SignUp} />
  </div>
</Router>
  • 点击跳转路由的声明式<Link to="/SignUp"> </Link>
  • 编程式导航,通过调用history的API
    组件里通过this.props.history.push('/')使用,
    组件之外通过history.push('/')使用。

相关文章

网友评论

      本文标题:React + Ts 番茄钟总结

      本文链接:https://www.haomeiwen.com/subject/taeslctx.html