From e5a12f7bd6b722a9f285fbe823d41021da37426b Mon Sep 17 00:00:00 2001 From: dhb Date: Wed, 12 May 2021 15:50:49 +0800 Subject: [PATCH] feat: when click the top menu can only switch the left menu --- src/page/index/index.vue | 27 +++++++++++++++++---------- 1 file changed, 17 insertions(+), 10 deletions(-) diff --git a/src/page/index/index.vue b/src/page/index/index.vue index d5625a3..651d488 100644 --- a/src/page/index/index.vue +++ b/src/page/index/index.vue @@ -111,19 +111,26 @@ export default { if (item.path) { itemActive = item; } else { - if (this.menu[childItemActive].length == 0) { - itemActive = this.menu[childItemActive]; - } else { - itemActive = this.menu[childItemActive].children[childItemActive]; + if (this.menu[childItemActive]) { + if (this.menu[childItemActive].length === 0) { + itemActive = this.menu[childItemActive]; + } else { + if (this.menu[childItemActive].children) { + itemActive = this.menu[childItemActive].children[childItemActive]; + } + } } } this.$store.commit('SET_MENUID', item); - this.$router.push({ - path: this.$router.$avueRouter.getPath({ - name: itemActive.label, - src: itemActive.path - }, itemActive.meta) - }); + // 如果path不为空才执行跳转页面 + if (itemActive.path) { + this.$router.push({ + path: this.$router.$avueRouter.getPath({ + name: itemActive.label, + src: itemActive.path + }, itemActive.meta) + }); + } } }); -- Gitee