diff --git a/src/views/main-header.vue b/src/views/main-header.vue index f9dddf3..4001bac 100644 --- a/src/views/main-header.vue +++ b/src/views/main-header.vue @@ -8,7 +8,9 @@ v-for="v in navList1" :key="v.path" class="nav-item" - :class="{ active: activePath === v.path }" + :class="{ + active: v.path === '/' ? activePath === v.path : new RegExp(`^${v.path}`).test(activePath) + }" @click="onNavItemClick(v.path)" > {{ v.name }} @@ -19,7 +21,7 @@ class="icon" v-for="v in navList2" :key="v.path" - :class="{ active: activePath === v.path }" + :class="{ active: new RegExp(`^${v.path}`).test(activePath) }" @click="onNavItemClick(v.path)" >