docs_vue2/app/router.scrollBehavior.js
2021-10-18 18:52:29 +08:00

17 lines
256 B
JavaScript

export default function scrollBehavior (to) {
if (to.hash) {
// scroll to anchor by returning the selector
return {
selector: decodeURIComponent(to.hash),
offset: {
y: 20
}
}
}
return {
x: 0,
y: 0
}
}