diff --git a/pages/index/category.vue b/pages/index/category.vue index f316b6aa..8111bf73 100644 --- a/pages/index/category.vue +++ b/pages/index/category.vue @@ -23,7 +23,7 @@ scroll-y :style="[{ height: pageHeight + 'px' }]" v-if="state.categoryList?.length" - @scrolltolower="handleScrollToLower" + @scrolltolower="handleScrollToLower" > category.id === params.id); + const foundCategory = state.categoryList.find((category) => category.id === Number(params.id)); // 如果找到则调用 onMenu 自动勾选相应分类,否则调用 onMenu(0) 勾选第一个分类 onMenu(foundCategory ? state.categoryList.indexOf(foundCategory) : 0); }); function handleScrollToLower() { loadMore(); - }; + }