Browse Source

修复关于我们本页面点击icon锚点跳转失效的异常

ming 11 months ago
parent
commit
433e2ba956
2 changed files with 10 additions and 8 deletions
  1. 1 1
      src/components/layout/feedFix.vue
  2. 9 7
      src/views/about/index.vue

+ 1 - 1
src/components/layout/feedFix.vue

@@ -25,7 +25,7 @@ function scrollToTop() {
 <template>
 <div class="feedBackBox">
     <div class="contactOne">
-        <a href="/about#hasAhchor"><img src="@/assets/img/home/f_phone.png" alt="" ></a>
+        <a href="/about?type=ahchor"><img src="@/assets/img/home/f_phone.png" alt="" ></a>
         <!-- <ul class="contactInner">
             <li style="font-size:25px;margin-bottom:5px">合作共赢</li>
             <li>

+ 9 - 7
src/views/about/index.vue

@@ -10,18 +10,20 @@ export default defineComponent({
         let oldCategoryId= ref()
 
         console.log(store.state.columnTypes)
-        if (store.state.route.hash) {
+        if (store.state.route.query.type) {
             setTimeout(()=>{
-
                 var  ids = store.state.columnTypes.filter(item => item.title == '联系我们');
                 console.log(ids[0].id)
                 
                 var ahchorEle = ids[0].id
-                console.log(document.getElementById(ahchorEle))
-                document.getElementById(ahchorEle).scrollIntoView({
-                    behavior: 'smooth' // 可选,平滑滚动效果
-                })
-            },1)
+                if(typeof window !== 'undefined' && typeof window.globalThis.addEventListener === 'function') {
+                    document.getElementById(ahchorEle).scrollIntoView({
+                        behavior: 'smooth' // 可选,平滑滚动效果
+                    })
+                }
+
+                
+            },10)
         }