watch(() => router.currentRoute.value.path, (toPath) => {
checkCurrentRoute(toPath)
})
const checkCurrentRoute = (current) => {
for (const item of menus.value) {
if (item.path === current) {
activeRoute.value = item.path
} else if (item.children) {
const subitem = item.children.find(v => v.path === current)
if (subitem) {
activeRoute.value = item.subview ? item.path : current
}
} else {
activeRoute.value = current
}
}
}
网友评论