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>
相关推荐
小陈工17 小时前
Python Web开发入门(十三):API版本管理与兼容性——让你的接口优雅地“长大”
开发语言·前端·人工智能·python·安全·oracle
李宏伟~17 小时前
大文件分片案例html + nodejs + 视频上传案例
javascript·html·音视频
计算机学姐17 小时前
基于SpringBoot的在线学习网站平台【个性化推荐+数据可视化+课程章节学习】
java·vue.js·spring boot·后端·学习·mysql·信息可视化
焦糖玛奇朵婷17 小时前
盲盒小程序开发,盲盒小程序怎么做
java·大数据·服务器·前端·小程序
豆苗学前端17 小时前
技术复盘文档:HTTPS 站点安全下载 HTTP 资源实践总结
前端
南囝coding17 小时前
Claude Code 多 Agent 协作:Subagents 和 Agent Teams 怎么选?
前端·后端
史迪仔011217 小时前
[QML] QT5和QT6 圆角的不同设置方法
前端·javascript·qt
暴力袋鼠哥17 小时前
基于 Django 与 Vue 的汽车数据分析系统设计与实现
vue.js·django·汽车
Z_Wonderful17 小时前
React react-app-env.d.ts是 TypeScript 的全局类型声明文件,它的作用
前端·react.js·typescript
码云之上17 小时前
从 SQL DDL 到 ER 图:前端如何优雅地实现数据库可视化
前端·数据库·数据可视化