diff --git a/themes/gitbook/components/NavPostList.js b/themes/gitbook/components/NavPostList.js index 2c7fceff..be84e9ba 100644 --- a/themes/gitbook/components/NavPostList.js +++ b/themes/gitbook/components/NavPostList.js @@ -61,10 +61,12 @@ const NavPostList = props => { // 如果都没有选中默认打开第一个 useEffect(() => { - if (expandedGroups.length === 0) { - setExpandedGroups([0]) - } - }, []) + setTimeout(() => { + if (expandedGroups.length === 0) { + setExpandedGroups([0]) + } + }, 500) + }, [router]) // 折叠项切换,当折叠或展开数组时会调用 const toggleItem = index => {