瀏覽代碼

update anchor (#1829)

杨奕 8 年之前
父節點
當前提交
b158e124da
共有 1 個文件被更改,包括 4 次插入4 次删除
  1. 4 4
      examples/app.vue

+ 4 - 4
examples/app.vue

@@ -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);
         }
       }