Vue-router路由回退/指定回退
Q: 不是应该用window.history.go(-1)吗? A: 不是的~
Q: 物理返回控制不了啊? A: 可以的~
Q: 666
路由回退
this.$router.go(-1);指定回退
mounted() { //window.scrollTo(0, 0); if (window.history && window.history.pushState) { history.pushState(null, null, document.URL); window.addEventListener('popstate', this.keyBack, false); /* false阻止默认事件 */ } } destroyed() { window.removeEventListener('popstate', this.keyBack, false); /* false阻止默认事件 */ } methods: { keyBack() { return this.$router.push('/'); } }