diff --git a/src/pages/data/list/index.vue b/src/pages/data/list/index.vue index d0e6b69..b4fb0a6 100644 --- a/src/pages/data/list/index.vue +++ b/src/pages/data/list/index.vue @@ -341,19 +341,31 @@ export default { }, // 分类展开及点击回调 selectType(index, indexPath) { - console.log(index, indexPath) let introduce = '' let dataSource = '' this.keyword = '' let list = this.typeList let select = '' + // 获取最里层的第一个子级id + function getDeepest(data) { + if (data[0].children && data[0].children.length) { + getDeepest(data[0].children) + } else { + select = data[0].id + } + } function handleData(data) { data.map((n, i) => { // 匹配到点击的分类,默认展开子级第一个分类 if (n.id == index) { if (n.introduce) introduce = n.introduce if (n.dataSource) dataSource = n.dataSource - if (!select) select = n.children.length ? (n.children[0].children.length ? n.children[0].children[0].id : n.children[0].id) : n.id + // 如果有子级,则递归取到最下面的第一级子级id,如果没有子级,则取当前id + if (n.children.length) { + getDeepest(n.children) + } else { + select = index + } } else { handleData(n.children) } diff --git a/src/pages/stat/list/index.vue b/src/pages/stat/list/index.vue index 9345d8a..47d62f3 100644 --- a/src/pages/stat/list/index.vue +++ b/src/pages/stat/list/index.vue @@ -70,7 +70,7 @@ -
+
展开更多