论坛交流增加滚动

This commit is contained in:
谢思 2025-12-29 19:56:39 +08:00
parent 0c673a40fb
commit 8e5264f305
1 changed files with 15 additions and 5 deletions

View File

@ -42,6 +42,18 @@ function List(props) {
2: require('../image/icon4.png'),
}
function init(updatedTags){
const tagByState = updatedTags.filter(i=>i.title.includes(tagNameByState))
setForumTagDetail(tagByState && !!tagByState.length ? tagByState[0] : updatedTags[0]);
if(tagByState && !tagByState.length) return
const targetDiv = document.getElementById("forums-list3-id");
const targetDivRect = targetDiv.getBoundingClientRect();
targetDiv && window.scrollTo({
top: targetDivRect.top+window.screenY,
behavior: 'smooth'
})
}
useEffect(() => {
document.title = '论坛交流';
@ -91,16 +103,14 @@ function List(props) {
.then(updatedTags => {
setForumTag(updatedTags);
if (updatedTags.length > 0) {
const tagByState = updatedTags.filter(i=>i.title.includes(tagNameByState))
setForumTagDetail(tagByState && !!tagByState.length ? tagByState[0] : updatedTags[0]);
init(updatedTags)
}
})
.catch(error => {
//
setForumTag(childrenTags);
if (childrenTags.length > 0) {
const tagByState = updatedTags.filter(i=>i.title.includes(tagNameByState))
setForumTagDetail(tagByState && !!tagByState.length ? tagByState[0] : updatedTags[0]);
init(childrenTags)
}
});
}
@ -171,7 +181,7 @@ function List(props) {
</div>
<div className="forums-list3-box">
<div className="font-40 font-bd center mb20">精华论坛</div>
<div className="width1600 pb100">
<div className="width1600 pb100" id="forums-list3-id">
{/* 四个板块 */}
<div className="forums-section-box df">
{forumTag.map((item, index) => {