解决点击路由时让页面置顶(在未自定义滚动条时有效)
router.beforeEach((to, from, next) => {
// 解决点击路由时页面置顶(未自定义滚动条时有效)
// chrome
document.body.scrollTop = 0;
// firefox
document.documentElement.scrollTop = 0;
// safari
window.pageYOffset = 0;
next();
});
解决ElementUI导航栏中的vue-router重复点菜单报错问题
import Vue from "vue";
import VueRouter from "vue-router";
const originalPush = VueRouter.prototype.push
VueRouter.prototype.push = function push(location) {
return originalPush.call(this, location).catch(err => err)
}