mirror of https://github.com/ElemeFE/element
update anchor (#1829)
parent
5027e86d4f
commit
b158e124da
|
@ -160,13 +160,13 @@
|
|||
|
||||
goAnchor() {
|
||||
if (location.href.match(/#/g).length > 1) {
|
||||
const auchor = location.href.match(/#[^#]+$/g);
|
||||
if (!auchor || auchor.length !== 1) return;
|
||||
const elm = document.querySelector(auchor[0]);
|
||||
const anchor = location.href.match(/#[^#]+$/g);
|
||||
if (!anchor) return;
|
||||
const elm = document.querySelector(anchor[0]);
|
||||
if (!elm) return;
|
||||
|
||||
setTimeout(_ => {
|
||||
document.documentElement.scrollTop = document.body.scrollTop = elm.offsetTop;
|
||||
document.documentElement.scrollTop = document.body.scrollTop = elm.offsetTop + 120;
|
||||
}, 50);
|
||||
}
|
||||
}
|
||||
|
|
Loading…
Reference in New Issue