import Vue from "vue";
import VueRouter from "vue-router";
Vue.use(VueRouter);
// 避免重复跳转同一个路由
const originalPush = VueRouter.prototype.push;
VueRouter.prototype.push = function push(location) {
return originalPush.call(this, location).catch(err => err);
};
const originalReplace = VueRouter.prototype.replace
VueRouter.prototype.replace = function replace(location) {
return originalReplace.call(this, location).catch(err => err)
}
const router=[路由]
const router = new VueRouter({
mode: "history",
routes
});
// 切换页面时滚动条自动滚动到顶部--body是fixed布局
router.afterEach(() => {
document.querySelector("body").scrollTop = 0;
});
export default router;