您的位置:首页 > 技术中心 > 前端框架 >

react中push与replace的区别是什么

时间:2020-12-23 18:01

react中push与replace的区别:push跳转会形成history,可返回到上一层;而replace跳转不会形成history,不可返回到上一层,适用于登录后,不需要重新回到登页面。

本教程操作环境:windows7系统、react16版本,该方法适用于所有品牌电脑。

相关教程推荐:React视频教程

react中push与replace的区别

push: a-b-c,可以回到上一级

push跳转会形成history,可返回到上一层。

语法:

this.props.history.push('router地址')

replace: a-b-c 回不到上一级 适用于登录后,不需要重新回到登页面

replace跳转不会形成history,不可返回到上一层。

语法:

this.props.history.replace('router地址')

更多编程相关知识,请访问:编程教学!!

以上就是react中push与replace的区别是什么的详细内容,更多请关注www.gxlsystem.com其它相关文章!

本类排行

今日推荐

热门手游