使用push的话 会导致返回历史有记录
this.$router.push({
query: {
id: this.processId
}
})
所以需要使用
this.$router.replace({
query: {
id: this.processId
}
})
虽然不影响使用,但是会报如下错误
解决方案 在router.js加上这段
import VueRouter from 'vue-router'
const originalReplace = VueRouter.prototype.replace
VueRouter.prototype.replace = function replace (location) {
return originalReplace.call(this, location).catch(err => err)
}
// push的同理
const originalPush = VueRouter.prototype.push
VueRouter.prototype.push = function push (location) {
return originalPush.call(this, location).catch(err => err)
}
注 适用于3.0.0版本的vue-router, 3.4.x可能会报错.catch获取不到