V0.1.2.20250718
——————————————— 1.路由重定向 2.Home页面头部完成 ———————————————
This commit is contained in:
parent
1614b560ff
commit
aca3aa8f6b
@ -2,9 +2,11 @@
|
|||||||
import "@/assets/ordinary/Home.css"
|
import "@/assets/ordinary/Home.css"
|
||||||
import {ref} from 'vue'
|
import {ref} from 'vue'
|
||||||
import { UserFilled } from '@element-plus/icons-vue'
|
import { UserFilled } from '@element-plus/icons-vue'
|
||||||
const activeIndex = ref('1')
|
import {useRouter} from "vue-router";
|
||||||
const handleSelect = (key: string, keyPath: string[]) => {
|
const router = useRouter()
|
||||||
console.log(key, keyPath)
|
const activeIndex = ref(router.currentRoute.value.path) // 根据当前路由设置激活状态
|
||||||
|
const handleSelect = (path: string) => {
|
||||||
|
router.push(path)
|
||||||
}
|
}
|
||||||
</script>
|
</script>
|
||||||
|
|
||||||
@ -18,12 +20,13 @@ const handleSelect = (key: string, keyPath: string[]) => {
|
|||||||
mode="horizontal"
|
mode="horizontal"
|
||||||
:ellipsis="false"
|
:ellipsis="false"
|
||||||
@select="handleSelect"
|
@select="handleSelect"
|
||||||
|
router
|
||||||
>
|
>
|
||||||
<!-- 左侧菜单项 -->
|
<!-- 左侧菜单项 -->
|
||||||
<el-menu-item index="1">首页</el-menu-item>
|
<el-menu-item index="/" :route="{ path: '/'}">首页</el-menu-item>
|
||||||
<el-menu-item index="2">图书</el-menu-item>
|
<el-menu-item index="/books" :route="{ path: '/books'}">图书</el-menu-item>
|
||||||
<el-menu-item index="3">期刊</el-menu-item>
|
<el-menu-item index="/journals" :route="{ path: '/journals'}">期刊</el-menu-item>
|
||||||
<el-menu-item index="4">报纸</el-menu-item>
|
<el-menu-item index="/newspapers" :route="{ path: '/newspapers'}">报纸</el-menu-item>
|
||||||
<!-- 弹性空间 -->
|
<!-- 弹性空间 -->
|
||||||
<div class="flex-grow"></div>
|
<div class="flex-grow"></div>
|
||||||
<!-- 头像-->
|
<!-- 头像-->
|
||||||
@ -35,6 +38,9 @@ const handleSelect = (key: string, keyPath: string[]) => {
|
|||||||
<div class="h-6"/>
|
<div class="h-6"/>
|
||||||
</div>
|
</div>
|
||||||
</header>
|
</header>
|
||||||
|
<div>
|
||||||
|
|
||||||
|
</div>
|
||||||
</template>
|
</template>
|
||||||
|
|
||||||
<style scoped>
|
<style scoped>
|
||||||
|
Loading…
x
Reference in New Issue
Block a user