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