美文网首页
react-router

react-router

作者: YC____ | 来源:发表于2018-12-10 20:26 被阅读5次

react-router是做SPA时,通过控制不同的URL来渲染不同的组件

1.Router 最基本的组件,保持url和ui同步
2.Route 用来声明路由的组件
3.Link 用来跳转的组件 用this.props.location.search来获取参数 可以受使用URLSearchParams来格式化参数,具体属性看mdn 使用this.props.history.push来跳转
4.通过mactch来获取当前的url
5.当取不到this.props.history的时候使用withRouter

相关文章

网友评论

      本文标题:react-router

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