1、解决报错:
// router/index.js
import Vue from 'vue'
import VueRouter from 'vue-router'
Vue.use(VueRouter)
// 解决报错👇
const routerPush = VueRouter.prototype.push
VueRouter.prototype.push = function push(location) {
return routerPush.call(this, location).catch(error => error)
}
2、解决跳转路由携带参数,但是不刷新(携带的参数键名是啥就写啥)
// APP.VUE
<template>
<div id="app">
// 解决无法重渲染问题
<router-view :key="$route.query.id"/>
</div>
</template>