diff --git a/src/views/ordinary/Home.vue b/src/views/ordinary/Home.vue index 2fa13e2..b8d4e64 100644 --- a/src/views/ordinary/Home.vue +++ b/src/views/ordinary/Home.vue @@ -2,9 +2,11 @@ import "@/assets/ordinary/Home.css" import {ref} from 'vue' import { UserFilled } from '@element-plus/icons-vue' -const activeIndex = ref('1') -const handleSelect = (key: string, keyPath: string[]) => { - console.log(key, keyPath) +import {useRouter} from "vue-router"; +const router = useRouter() +const activeIndex = ref(router.currentRoute.value.path) // 根据当前路由设置激活状态 +const handleSelect = (path: string) => { + router.push(path) } @@ -18,12 +20,13 @@ const handleSelect = (key: string, keyPath: string[]) => { mode="horizontal" :ellipsis="false" @select="handleSelect" + router > - 首页 - 图书 - 期刊 - 报纸 + 首页 + 图书 + 期刊 + 报纸
@@ -35,6 +38,9 @@ const handleSelect = (key: string, keyPath: string[]) => {
+
+ +