React中返回上一页,返回前两页方法 在 class 组件中 返回上一页 this.props.history.goBack() // 返回上一页 this.props.history.go(-2) // 返回前两页 在hook组件中 import { useHistory } from 'react-router-dom' const Example = (props) => { const history = useHistory() history.goBack() // 返回上一页 history.go(-2) // 返回前两页 }