Toggle navigation
Toggle navigation
This project
Loading...
Sign in
Hooke
/
mlaj
Go to a project
Toggle navigation
Toggle navigation pinning
Projects
Groups
Snippets
Help
Project
Activity
Repository
Pipelines
Graphs
Issues
0
Merge Requests
0
Wiki
Snippets
Network
Create a new issue
Builds
Commits
Issue Boards
Authored by
hookehuyr
2025-03-25 17:51:01 +0800
Browse Files
Options
Browse Files
Download
Email Patches
Plain Diff
Commit
799198ac710e1968372c8ea063d6eb2a0aad269f
799198ac
1 parent
76d76337
feat(HomePage): 添加内容区域滚动重置功能
在切换标签时,重置内容区域的位置,确保用户无需手动滚动即可看到新内容
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
16 additions
and
2 deletions
src/views/HomePage.vue
src/views/HomePage.vue
View file @
799198a
<!--
* @Date: 2025-03-20 19:55:21
* @LastEditors: hookehuyr hookehuyr@gmail.com
* @LastEditTime: 2025-03-25 1
6:44:51
* @LastEditTime: 2025-03-25 1
7:48:53
* @FilePath: /mlaj/src/views/HomePage.vue
* @Description: 亲子学院首页组件
*
...
...
@@ -282,7 +282,7 @@
</div>
<!-- Content Based on Active Tab -->
<div class="px-4 mt-5">
<div class="px-4 mt-5"
ref="contentRef"
>
<!-- Recommended Content -->
<div v-if="activeTab === '推荐'">
<!-- Personalized Recommendations -->
...
...
@@ -674,4 +674,18 @@ onUnmounted(() => {
clearInterval(carouselInterval)
}
})
const contentRef = ref(null) // 内容区域的ref引用
// 监听activeTab变化,重置内容区域位置
watch(activeTab, () => {
if (contentRef.value) {
const navHeight = document.querySelector('.sticky').offsetHeight;
const marginTop = parseInt(window.getComputedStyle(contentRef.value).marginTop);
window.scrollTo({
top: contentRef.value.offsetTop - navHeight - marginTop,
behavior: 'smooth'
});
}
})
</script>
...
...
Please
register
or
login
to post a comment