fix(cli): fix anchor

This commit is contained in:
chenjiahan
2020-11-21 20:35:06 +08:00
parent 27c7d839c0
commit a13d43c802
4 changed files with 11 additions and 9 deletions
+5 -3
View File
@@ -88,9 +88,11 @@ export default {
},
mounted() {
if (this.$route.hash) {
scrollToAnchor(this.$route.hash);
}
setTimeout(() => {
if (this.$route.query.anchor) {
scrollToAnchor(this.$route.query.anchor);
}
});
},
methods: {
+1 -1
View File
@@ -2,7 +2,7 @@ export function scrollToAnchor(selector) {
let count = 0;
const timer = setInterval(() => {
const el = document.querySelector(selector);
const el = document.querySelector('#' + selector);
if (el) {
el.scrollIntoView();
clearInterval(timer);