diff --git a/src/forums/list/index.jsx b/src/forums/list/index.jsx index 756fed096..2e7618a80 100644 --- a/src/forums/list/index.jsx +++ b/src/forums/list/index.jsx @@ -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) {
精华论坛
-
+
{/* 四个板块 */}
{forumTag.map((item, index) => {