前端页面跳转

页面跳转

1. history.push()
2. window.open()
3. window.location.href
4. window.location.Reload()

1) 同一个项目内的跳转直接用:history.push(‘路由信息’) ,因为在本项目内已配置相应的路由。

2)不同项目内的跳转(由一个项目跳转到另一个项目,没有相应的路由配置),使用 window.open(‘路由信息’) 或者 window.location.Reload(路由信息)、 window.location.href=‘路由信息’。
注意:window.location.href 会刷新页面,所以使用的时候要注意,特别是在react 工程中使用 model 存储数据时,会导致数据存储失败。

3)window.location.href 和 window.location.Reload()都是刷新当前页面,区别在于是否有提交数据。当有提交数据时,window.location.Reload()会提示是否提交,window.location.href 则是向指定的url提交数据

猜你喜欢

转载自blog.csdn.net/baidu_25051161/article/details/119675650