docs_vue2/app/router.scrollBehavior.js

17 lines
256 B
JavaScript
Raw Normal View History

2020-08-13 11:47:56 +08:00
export default function scrollBehavior (to) {
2021-10-18 18:52:29 +08:00
if (to.hash) {
2020-08-13 11:47:56 +08:00
// scroll to anchor by returning the selector
2021-10-18 18:52:29 +08:00
return {
selector: decodeURIComponent(to.hash),
offset: {
y: 32
2021-10-18 18:52:29 +08:00
}
}
}
return {
x: 0,
y: 0
2020-08-13 11:47:56 +08:00
}
}