vue - router routing Jump error, NavigationDuplicated

vue-router ≥3.0 version callback form and change the form of the promise api, return a promise, the same as if the routing address of the jump, and does not capture the error, the console will always warning (as shown Note: the following version 3.0 does not appear the following warning !!!, due to routing a call back ...)

Option One:
Installation vue-router3.0 the following versions: 3.0 or later uninstall the old version and then install npm install @ vue-router2.8.0 -S

Option II:
for the jump to the same address add routing catch capture at the exception:.. This $ router.push ( ' / location') catch (err => {console.log (err)})

Option Three:
Registration can be a global function in main.js

import Router from 'vue-router'

const originalPush = Router.prototype.push
Router.prototype.push = function push(location) {
return originalPush.call(this, location).catch(err => err)
}

Note: The official version of the new route vue-router default callback return is promise, on the original version of the route will be abandoned callbacks! ! ! !
----------------
Original link: https: //blog.csdn.net/weixin_45522694/article/details/99548714

Guess you like

Origin www.cnblogs.com/xiaofenguo/p/11570835.html