排错

优质
小牛编辑
151浏览
2023-12-01

如何获得上一次路径?

  1. <Route component={App}>
  2. {/* ... 其它 route */}
  3. </Route>
  4. const App = React.createClass({
  5. getInitialState() {
  6. return { showBackButton: false }
  7. },
  8. componentWillReceiveProps(nextProps) {
  9. const routeChanged = nextProps.location !== this.props.location
  10. this.setState({ showBackButton: routeChanged })
  11. }
  12. })