美文网首页
vue路由的几个注意点

vue路由的几个注意点

作者: 放任自由f0 | 来源:发表于2021-06-10 13:29 被阅读0次

路由重复点击有报错解决
import Vue from "vue";
import Router from "vue-router";
const originalPush = Router.prototype.push;
Router.prototype.push = function push (location) {
return originalPush.call(this, location).catch(err => err)
}
Vue.use(Router);

router清除add添加的路由
经常用于换用户登录不刷新的情况
const createRouter = () =>
new Router({
mode: "history",
scrollBehavior: () => ({ x: 0, y: 0 }),
routes: constantRoutes,
});

const router: any = createRouter();

export function resetRouter() {
const newRouter: any = createRouter();
router.matcher = newRouter.matcher;
}
export default router;

相关文章

网友评论

      本文标题:vue路由的几个注意点

      本文链接:https://www.haomeiwen.com/subject/azvdeltx.html