update anchor (#1829)

pull/1873/head
杨奕 2016-12-20 16:38:21 +08:00 committed by baiyaaaaa
parent 5027e86d4f
commit b158e124da
1 changed files with 4 additions and 4 deletions

View File

@ -160,13 +160,13 @@
goAnchor() { goAnchor() {
if (location.href.match(/#/g).length > 1) { if (location.href.match(/#/g).length > 1) {
const auchor = location.href.match(/#[^#]+$/g); const anchor = location.href.match(/#[^#]+$/g);
if (!auchor || auchor.length !== 1) return; if (!anchor) return;
const elm = document.querySelector(auchor[0]); const elm = document.querySelector(anchor[0]);
if (!elm) return; if (!elm) return;
setTimeout(_ => { setTimeout(_ => {
document.documentElement.scrollTop = document.body.scrollTop = elm.offsetTop; document.documentElement.scrollTop = document.body.scrollTop = elm.offsetTop + 120;
}, 50); }, 50);
} }
} }