tj
2025-03-17 9a2bb3ba61d653bf2ed75c19c8ee664accade482
关于我们跳转到首页锚点
已修改3个文件
20 ■■■■ 文件已修改
src/components/HeaderMenu.vue 7 ●●●● 补丁 | 查看 | 原始文档 | blame | 历史
src/pages/Home.vue 2 ●●● 补丁 | 查看 | 原始文档 | blame | 历史
src/router/index.ts 11 ●●●●● 补丁 | 查看 | 原始文档 | blame | 历史
src/components/HeaderMenu.vue
@@ -8,7 +8,7 @@
                </el-menu-item>
                <el-menu-item index="/">首页</el-menu-item>
                <el-menu-item index="/product">产品中心</el-menu-item>
                <el-menu-item index="/contact">联系我们</el-menu-item>
                <!-- <el-menu-item index="/contact">联系我们</el-menu-item> -->
                <el-menu-item index="/about">关于我们</el-menu-item>
            </el-menu>
        </div>
@@ -37,7 +37,10 @@
    // console.log('选中菜单:', index);
    if(index === '/logo'){
        router.push('/');
    }else{
    }else if(index === '/about'){
        router.push({path:'/',hash:'#third-other'});
    }
    else{
        router.push(index);
    }
    
src/pages/Home.vue
@@ -54,7 +54,7 @@
      </div>
    </div>
    <div class="third-other">
    <div id="third-other" class="third-other">
      <el-row>
        <el-col :span="8">
          <div class="third-other-title">产品中心</div>
src/router/index.ts
@@ -13,7 +13,16 @@
const router = createRouter({
  history: createWebHistory(),
  routes
  routes,
  scrollBehavior(to, from, savedPosition) {
    if (to.hash) {
      return {
        el: to.hash,
        behavior: 'smooth'
      };
    }
    return savedPosition || { top: 0 };
  }
});
export default router;