refactor:优化会员中心菜单点击时的处理函数逻辑

This commit is contained in:
妙码生花 2024-11-11 15:53:54 +08:00
parent 028710bcb9
commit 674fe82f46

View File

@ -36,7 +36,7 @@
<div <div
v-for="(menu, index) in item.children" v-for="(menu, index) in item.children"
:key="index" :key="index"
@click="routerPush('', menu)" @click="routerPush(menu)"
class="user-menu-item" class="user-menu-item"
:class="route.fullPath == menu.path ? 'active' : ''" :class="route.fullPath == menu.path ? 'active' : ''"
> >
@ -60,10 +60,10 @@ const router = useRouter()
const userInfo = useUserInfo() const userInfo = useUserInfo()
const memberCenter = useMemberCenter() const memberCenter = useMemberCenter()
const routerPush = (routeName: string, route?: RouteRecordRaw) => { const routerPush = (route: string | RouteRecordRaw) => {
if (routeName) { if (typeof route === 'string') {
router.push({ name: routeName }) router.push({ name: route })
} else if (route) { } else {
onClickMenu(route) onClickMenu(route)
} }
} }