当前位置: 代码迷 >> 综合 >> 解决NavigationDuplicated: Avoided redundant navigation to current location: “/home“.报错问题
  详细解决方案

解决NavigationDuplicated: Avoided redundant navigation to current location: “/home“.报错问题

热度:31   发布时间:2023-12-15 09:16:52.0

prototype方法:

说明:prototype是函数对象上面预设的对象属性
    1. JS中所有的东西都是对象,每个对象都有prototype这个属性,这个属性是一个对(object)
    2. JS中所有的东西都由Object衍生而来, 即所有东西原型链的终点指向Object.prototype
    3. JS中构造函数和实例(对象)之间有微妙的关系,构造函数通过定义prototype来约定其实例规格, 再通过 new 来构造出实例, 他们的作用就是生产对象。而构造函数(方法)本身又是方法 (Function)的实例, 因此也可以查到它的__proto__(原型链)

main.js文件中加上如下图所示代码段即可。 

import VueRouter from 'vue-router'Vue.use(VueRouter)// 解决ElementUI导航栏中重复点菜单报错问题
const originalPush = VueRouter.prototype.push
VueRouter.prototype.push = function push(location) {return originalPush.call(this, location).catch(err => err)
}

  相关解决方案