方法一:使用history库
1.导入history库(由react-router团队开发,为react-router依赖库)
2.安装:
yarn add history
3.使用:
import { createHashHistory } from 'history'
const history = createHashHistory({window})
const backHandle = ()=>{
history.go(-1)
}
方法二:使用HTML5原生方法
window.history.back()
最后
以上就是等待小蜜蜂最近收集整理的关于React开发中如何返回上级导航的方法的全部内容,更多相关React开发中如何返回上级导航内容请搜索靠谱客的其他文章。
本图文内容来源于网友提供,作为学习参考使用,或来自网络收集整理,版权属于原作者所有。
发表评论 取消回复