vue 解決重復(fù)點(diǎn)擊路由報(bào)錯(cuò)問(wèn)題
import Vue from 'vue'
import Router from 'vue-router'
Vue.use(Router)
//以下代碼解決路由地址重復(fù)點(diǎn)擊的報(bào)錯(cuò)問(wèn)題
const originalPush = Router.prototype.push
Router.prototype.push = function push(location) {
return originalPush.call(this, location).catch(err => err)
}
const originalPushs = Vuerouter.prototype.replace
Vuerouter.prototype.replace = function replace(location) {
return originalPushs.call(this, location).catch(err => err)
}
如何還是不行你可能沒(méi)有安裝下面命名
npm i vue-router@3.0 -S
npm install