开发指南 开发指南
React Router 中文文档
TypeScript 中文文档
gitee (opens new window)
React Router 中文文档
TypeScript 中文文档
gitee (opens new window)
  • 首页
  • 1、简介
  • 2、基础
    • 路由配置
    • 路由匹配原理
    • History
    • 默认路由(IndexRoute)与 IndexLink
  • 3、高级用法
    • 动态路由
    • 跳转前确认
    • 服务端渲染
    • 组件生命周期
    • 组件外部跳转
  • 4、升级指南
  • 5、排错
    • 6、API文档
    • 7、词汇表

    # 排错

    # 如何获得上一次路径?

    <Route component={App}>
      {/* ... 其它 route */}
    </Route>
    
    const App = React.createClass({
      getInitialState() {
        return { showBackButton: false }
      },
    
      componentWillReceiveProps(nextProps) {
        const routeChanged = nextProps.location !== this.props.location
        this.setState({ showBackButton: routeChanged })
      }
    })
    

    ← 4、升级指南 6、API文档 →

    内容转载自开源项目React Router中文文档
    React Router 中文文档 | 赣公网安备 36012102000277号 | 赣ICP备2021002441号-2