在添加如下步骤后报错,但是不影响使用:
activated(){
this.$router.push(this.path);
},
解决办法:
在router文件夹下的index.js中加入如下代码,错误消失
import Vue from 'vue'
import VueRouter from 'vue-router'
//import HelloWorld from '@/components/HelloWorld'
const originalPush = VueRouter.prototype.push
VueRouter.prototype.push = function push(location) {
return originalPush.call(this, location).catch(err => err)
}
本文解决了一个常见的Vue应用中遇到的路由push方法导致的错误。通过修改VueRouter的原型方法,可以有效避免错误的发生,确保应用的正常运行。
7017

被折叠的 条评论
为什么被折叠?



