vue和js替换当前路由的几种方式
- 使用vue-router的replace方法:
this.$router.replace('/newRoute')
- 使用window.location.replace方法:
window.location.replace('/newRoute')
- 使用history.replaceState方法:
history.replaceState(null, '', '/newRoute')
注意:使用第二种和第三种方法会刷新页面,而第一种方法不会。
原文地址: https://www.cveoy.top/t/topic/gjBx 著作权归作者所有。请勿转载和采集!