基于 react-router 4.0 版本,我们想要通过 JS 手动控制路由跳转,分三步:

第一步:引入 propTypes

const PropTypes = require('prop-types');

第二步:定义context 的router属性

BottomNavigationExampleSimple.contextTypes = {
  router: PropTypes.object
}

第三步:控制跳转

 handleClick= () => {
    this.context.router.history.replace('/index')
  };

相关文章:

  • 2021-06-20
  • 2022-12-23
  • 2022-12-23
  • 2022-12-23
  • 2021-06-08
  • 2022-12-23
  • 2022-12-23
  • 2021-05-17
猜你喜欢
  • 2022-12-23
  • 2022-12-23
  • 2022-12-23
  • 1970-01-01
  • 2022-01-17
  • 2022-12-23
  • 2022-12-23
相关资源
相似解决方案