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>
相关推荐
EndingCoder19 分钟前
类的继承和多态
linux·运维·前端·javascript·ubuntu·typescript
用户479492835691520 分钟前
React 终于出手了:彻底终结 useEffect 的"闭包陷阱"
前端·javascript·react.js
程序员猫哥27 分钟前
前端开发,一句话生成网站
前端
Younglina1 小时前
一个纯前端的网站集合管理工具
前端·vue.js·chrome
木头程序员1 小时前
前端(包含HTML/JavaScript/DOM/BOM/jQuery)基础-暴力复习篇
开发语言·前端·javascript·ecmascript·es6·jquery·html5
卖火箭的小男孩1 小时前
# Flutter Provider 状态管理完全指南
前端
小雨青年1 小时前
鸿蒙 HarmonyOS 6|ArkUI(01):从框架认知到项目骨架
前端
Null1551 小时前
浏览器唤起本地桌面应用(基础版)
前端·浏览器
哈__1 小时前
React Native 鸿蒙跨平台开发:PixelRatio 实现鸿蒙端图片的高清显示
javascript·react native·react.js
wszy18091 小时前
外部链接跳转:从 App 打开浏览器的正确姿势
java·javascript·react native·react.js·harmonyos