在router文件夹下的index.js中加入红色字体代码即可解决
import Vue from 'vue' import VueRouter from 'vue-router' Vue.use(VueRouter) const routes = [ { path: '/', name: 'Login', component: () => import('../views/Login.vue') }, { path: '/login', name: 'Login', component: () => import('../views/Login.vue') }, { path: '/home', name: 'Home', component: () => import('../views/Home.vue') } ] const router = new VueRouter({ routes }) const originalPush = VueRouter.prototype.push VueRouter.prototype.push = function push(location) { return originalPush.call(this, location).catch(err => err) } export default router