소스 검색

如果从主页点击某个分类进入分类页面,则自动选中左侧的一级分类

卢越 1 년 전
부모
커밋
b093f99ab5
1개의 변경된 파일9개의 추가작업 그리고 1개의 파일을 삭제
  1. 9 1
      pages/index/category.vue

+ 9 - 1
pages/index/category.vue

@@ -131,8 +131,16 @@
     getGoodsList();
   }
 
-  onLoad(async () => {
+  onLoad(async (params) => {
     await getList();
+	// 从主页点进来的时候自动选中左侧一级菜单
+	const cateList = state.categoryList
+	for (let index = 0; index < cateList.length;index++) {
+		if (cateList[index].id == params.id) {
+			state.activeMenu = index
+			break;
+		}
+	}
     // 如果是 first 风格,需要加载商品分页
     if (state.style === 'first_one' || state.style === 'first_two') {
       onMenu(0);