NavigationDuplicated: Avoided redundant

209 阅读1分钟

本文已参与「新人创作礼」活动,一起开启掘金创作之路 Vue出现

vue-router.esm.js?fe87:2065 

Uncaught (in promise) NavigationDuplicated: Avoided redundant navigation to current location:

解决办法:

在index.js文件添加

//获取原型对象上的push函数
const originalPush = Router.prototype.push
//修改原型对象中的push方法
 Router.prototype.push = function push(location) {
    return originalPush.call(this, location).catch(err => err)
 }

第二种办法

跳转的地方修改为

 this.$router.replace('/home').catch(err =>{err})