react中路由的跳转

1.react-router-dom

  使用react-router-dom 4.4.2  

  在页面中直接使用

  引入

i  mport { Link } from 'react-router-dom'
  使用
  <Link to={{ pathname: "/app/studyMapModule/detail" }} >detail</Link> 
  报错
  browser.js?fec5:49 Warning: Hash history cannot PUSH the same path; a new entry will not be added to the history stack
  原因:浏览器不会将同样的路径push到stack里
  解决--添加上replace
  
  <Link to={{ pathname: "/app/studyMapModule/detail" }} replace>detail</Link> 

猜你喜欢

转载自www.cnblogs.com/jcxfighting/p/9035898.html