如何解决NavigationDuplicated: Avoided redundant navigation to current location:问题

问题描述

在这里插入图片描述

解决方案

废话不多说


  • 打开router下边的index.js文件,然后复制粘贴以下代码段即可
let originPush = VueRouter.prototype.push
let originReplace = Vue.prototype.originReplace

VueRouter.prototype.push = function (location,res,rej) {
    
    
    if (res && rej ) {
    
    
        originPush.call(this,location,res,rej)
    } else {
    
    
        originPush.call(this,location,()=>{
    
    },()=>{
    
    })
    }
}

VueRouter.prototype.replace = function(location ,res,rej) {
    
    
    if (res && rej) {
    
    
        originReplace.call(this,location,res,rej)
    } else {
    
    
        originReplace.call(this,location,() => {
    
    },() => {
    
    })
    }
}

猜你喜欢

转载自blog.csdn.net/m0_60429030/article/details/127985890