vue 网站导航栏

vue 网站导航栏

html 复制代码
<template>
  <!-- 顶部导航栏 -->
  <header class="navbar">
    <div class="logo-area">
      <img src="" alt="" class="logoImg" />
      <span class="system-name">xxxx管理系统</span>
    </div>
    <el-menu mode="horizontal" :default-active="activeMenu" class="nav-menu" :ellipsis="false" @select="handleMenuChange">
      <el-menu-item index="index">首页</el-menu-item>
      <el-menu-item index="file" :class="{ active: activeIndex == 1 }">文件检索</el-menu-item>
      <el-menu-item index="list" :class="{ active: activeIndex == 2 }">成果列表</el-menu-item>
      <el-menu-item index="download" :class="{ active: activeIndex == 3 }">下载中心</el-menu-item>
      <el-menu-item index="help" :class="{ active: activeIndex == 4 }">帮助中心</el-menu-item>
    </el-menu>
  </header>
</template>

<script setup>
import { ref, defineProps } from 'vue'
import { useRoute, useRouter } from 'vue-router'

const props = defineProps({
  activeIndex: {
    type: Number,
    default: 1,
  },
})

const route = useRoute()
const router = useRouter()

const activeMenu = ref('download')

const handleMenuChange = (path) => {
  router.push({ path: path, query: {} })
}
</script>

<style lang="scss" scoped>
/* 顶部导航栏 */
.navbar {
  display: flex;
  justify-content: space-between;
  align-items: center;
  padding: 0 110px;
  height: 60px;
  background-color: #fff;
  box-shadow: 0 1px 4px rgba(0, 0, 0, 0.1);
}

.logo-area {
  display: flex;
  align-items: center;
}

.logo-icon {
  font-size: 24px;
  color: #409eff;
  margin-right: 8px;
}

.system-name {
  font-size: 18px;
  font-weight: bold;
  color: #303133;
}

.nav-menu {
  --el-menu-bg-color: transparent;
  --el-menu-active-text-color: $primary;
  --el-menu-text-color: #606266;
}

.nav-menu .active {
  border-bottom: 2px solid $primary;
}

.logoImg {
  width: 40px;
  height: 40px;
  border-radius: 8px;
  background: $primary;
  margin-right: 12px;
}
</style>
相关推荐
葡萄城技术团队6 小时前
1000 人协同压测的环境瓶颈排查:CPU 争用与 Wi\-Fi
前端
Java后端的Ai之路7 小时前
CAS并发控制-从CPU指令到企业级乐观锁
vue.js·人工智能·python·cas·乐观锁
excel7 小时前
Marked 与 Markdown 有什么区别?该怎么选?
前端
Da Da 泓8 小时前
五子棋 Web 端测试用例报告
前端·网络·websocket·网络协议·测试用例·项目
zxcvb1539 小时前
远程查看本地文档:一条轻量 Web 文件服务的工程化链路
前端·远程查看文档
niucloud-admin9 小时前
NIUCLOUD PHP SAAS上门家政使用文档:城市管理
java·前端·php
程序员大阳9 小时前
副队长JavaScript教程(50)-DOM:网页开发的起点
javascript·dom·es·节点·概念·document·关系
北岛贰9 小时前
啵啵音乐迎来全新升级!
前端
hkNaruto11 小时前
【AI】基于大模型的AI游戏地图生成、控制方案:AI Native Game Harness 迁移操作手册
前端·人工智能·游戏
IT_陈寒12 小时前
Java序列化踩坑记:对象循环引用让我加班两小时
前端·人工智能·后端