Elementvue router连续点击同一路由报错解决方法

mac2026-06-17  8

写项目的时候,多次点击同一路由地址的时候,router会报错,错误如下:

网上查了一下,发现是因为router版本bug,需要升级router ,方法如下(亲测有效) :

第一种方法,升级vue-router:

npm i vue-router@3.0 -S

第二种方法,不升级vue-router,修改main.js

// 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) }

以上,就能解决了

最新回复(0)