add scroll to top

This commit is contained in:
patarapolw committed 2019-08-27 14:16:52 +07:00
1 parent 1988ccfd5e
commit e04f6156cb
1 file changed
+12 -1
+12 -1
View File
@@ -14,7 +14,18 @@ const router = new Router({
{ path: "/p", component: Single },
{ path: "/p/:y/:mo/:name", component: Single },
{ path: "/about", component: About }
]
],
scrollBehavior(to, from, savedPosition) {
if (savedPosition) {
return savedPosition;
} else if (to.hash) {
return {
selector: to.hash
};
} else {
return { x: 0, y: 0 }
}
}
});
document.addEventListener("click", (ev) => {