fix: fix scroll timing

This commit is contained in:
Justineo 2021-10-20 10:24:04 +08:00
parent 0ec32cc672
commit 42f4ec1673
No known key found for this signature in database
GPG Key ID: B73F0979CF18A0EA

View File

@ -1,6 +1,13 @@
export default function scrollBehavior (to) { function timeout (t) {
return new Promise(resolve => {
setTimeout(resolve, t)
})
}
export default async function scrollBehavior (to) {
if (to.hash) { if (to.hash) {
// scroll to anchor by returning the selector // scroll to anchor by returning the selector
await timeout(0)
return { return {
selector: decodeURIComponent(to.hash), selector: decodeURIComponent(to.hash),
offset: { offset: {