[Solved] Vue router in the element UI navigation bar repeatedly clicks on the menu above version 3.0 and reports errors

Add the following code to the index.js file under the router folder:

import Router from 'vue-router'

// Solve the problem that vue-router in the navigation bar of ElementUI reports an error when repeatedly clicking the menu in version 3.0 or above

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

Similar Posts: