如何解决Vue-router中NavigationDuplicated错误问题?
- 内容介绍
- 文章标签
- 相关推荐
本文共计265个文字,预计阅读时间需要2分钟。
版本:3.1.x错误原因:使用 push()、replace() 进行导航时,不能重复导航到当前路由。解决方法:方法1:在定义路由的文件中(router/index.js)javascriptconst originalPush=VueRouter.prototype.push;VueRouter.prototype.push=function (location, resolve, reject) { if (this.isCurrentRoute(location)) return; originalPush.call(this, location, resolve, reject);};
版本:3.1.x
报错原因:
使用push()、replace()进行导航时,不能重复导航到当前路由。
本文共计265个文字,预计阅读时间需要2分钟。
版本:3.1.x错误原因:使用 push()、replace() 进行导航时,不能重复导航到当前路由。解决方法:方法1:在定义路由的文件中(router/index.js)javascriptconst originalPush=VueRouter.prototype.push;VueRouter.prototype.push=function (location, resolve, reject) { if (this.isCurrentRoute(location)) return; originalPush.call(this, location, resolve, reject);};
版本:3.1.x
报错原因:
使用push()、replace()进行导航时,不能重复导航到当前路由。

