Browse Source

锚点bug修复

lucky 2 years ago
parent
commit
3198b38908

+ 7 - 2
src/views/reportQuery/test/anchBook/anchor.vue

@@ -53,6 +53,7 @@ export default {
           childrenHeight += ele.children.length * 30;
         }
       });
+      console.log(childrenHeight + 30 * this.data.length - 20 + "px")
       return (childrenHeight + 30) * (this.data.length - 20) + "px";
     },
     //获取所有锚点组合的位置
@@ -140,14 +141,17 @@ export default {
       }
       //当前滚动位置
       let scrollTop = this.$refs["anchor-body"].scrollTop;
+      // console.log(scrollTop)
+      
       this.allAnchor.forEach((ele, i) => {
         let dom = document.querySelector(ele.tar);
         if (dom) {
           if (
-            scrollTop > dom.offsetTop &&
-            scrollTop <= dom.offsetTop + dom.offsetHeight / 3
+            scrollTop > dom.offsetTop-80
+         
           ) {
             this.currentAnchor = ele.tar;
+            // this.currentAnchor = this.allAnchor[i+1].tar;
             // this.$refs["anchor-icon"].style.display = "block";
             // this.$refs["anchor-icon"].style.top = i * 30 + 2 + "px";
             return;
@@ -210,6 +214,7 @@ export default {
     border-radius: 1px;
     position: relative;
     background-color: lightgrey;
+    display: none;
     .anchor-icon {
       position: absolute;
       width: 8px;

+ 3 - 1
src/views/reportQuery/test/detail.vue

@@ -1,5 +1,5 @@
 <template>
-  <div class="pagePadding">
+  <div >
     <Anchor height="900px" :data="anchorArray">
       <div style="width: 100%">
         <el-collapse v-model="activeNames" style="margin: -8px 0 0 0">
@@ -27,6 +27,7 @@
               >
               </editPrice>
             </el-collapse-item> -->
+      
           <div id="detail2">
             <el-collapse-item 
               title="采购——采购单"
@@ -270,6 +271,7 @@ export default {
       activeNames: [],
 
       anchorArray: [
+
         { tar: "#detail2", title: "采购——采购单" },
         { tar: "#detail3", title: "采购——入库单" },
         { tar: "#detail4", title: "采购——退货单" },