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>
相关推荐
m0_4592524617 分钟前
fastadmin动态渲染统计信息
开发语言·前端·javascript·php
该怎么办呢28 分钟前
Source/Core/Matrix4.js
前端·javascript
小江的记录本28 分钟前
【MyBatis-Plus】Spring Boot + MyBatis-Plus 进行各种数据库操作(附完整 CRUD 项目代码示例)
java·前端·数据库·spring boot·后端·sql·mybatis
console.log('npc')1 小时前
响应式布局的 Element UI、Ant Design 24栅格布局
vue.js·ui
于慨1 小时前
Capacitor
前端
该怎么办呢1 小时前
Source/Core/Event.js
开发语言·javascript·ecmascript·cesium
IT凝冬2 小时前
liunx 的 centos7 安装ngin
前端
赵锦川2 小时前
大屏比例缩放
前端·javascript·html
该怎么办呢2 小时前
Source/Core/DeveloperError.js
开发语言·javascript·ecmascript
于慨2 小时前
tauri
java·服务器·前端