设置router-link样式-使用a

设置样式图一变成图二

核心代码(ps a前面没有.)

有router-link 设置样式就用a就可以

css 复制代码
a{
    //background-color: #545c64;
    color: white;
    text-decoration: none; //去掉下划线
    &:hover {
      color: #00ce41;
      //background-color: #545c64;
    }
  }

完整代码

javascript 复制代码
<template>
  <div>
    <el-menu
        active-text-color="#ffd04b"
        background-color="#545c64"
        class="el-menu-vertical-demo"
        default-active="1"
        text-color="#fff"
        @open="handleOpen"
        @close="handleClose"
    >
      <el-sub-menu index="1">
        <template #title>
          <el-icon><location /></el-icon>
          <span>管理</span>
        </template>

          <el-menu-item index="1-1">
            <router-link class="router_active" :to="{path:'/'}">
              <span class="side-sp">用户管理</span>
            </router-link>
          </el-menu-item>
          <el-menu-item index="1-2">
            <router-link class="router_active" :to="{path:'/category'}">
              <span class="side-sp">分类管理</span>
            </router-link>
          </el-menu-item>
          <el-menu-item index="1-3">
            <router-link class="router_active" :to="{path:'/picture'}">
              <span class="side-sp">图片管理</span>
            </router-link>
          </el-menu-item>

      </el-sub-menu>
    </el-menu>
  </div>
</template>

<script setup lang="ts">
import {
  Document,
  Menu as IconMenu,
  Location,
  Setting,
} from '@element-plus/icons-vue'
const handleOpen = (key: string, keyPath: string[]) => {
  console.log(key, keyPath)
}
const handleClose = (key: string, keyPath: string[]) => {
  console.log(key, keyPath)
}
</script>

<style scoped lang="scss">
.el-menu-item{
  color: #fff;
  a{
    //background-color: #545c64;
    color: white;
    text-decoration: none; //去掉下划线
    &:hover {
      color: #00ce41;
      //background-color: #545c64;
    }
  }
  }



</style>
相关推荐
wyhwust6 分钟前
基于Apifox的接口管理工具
前端
柒和远方16 分钟前
后端认证、鉴权、高并发:从 Session 到 JWT 再到 Redis
前端·后端·面试
piglet1213816 分钟前
把搜索调到 Claude.ai 的水准
前端·人工智能
前端Hardy23 分钟前
前端圈沸腾!这个动画库月下载超 3000 万次,已经快成行业标准了
前端
文阿花36 分钟前
Echarts实现自动旋转柱状3D扇形图
前端·3d·echarts
sp4237 分钟前
使用 Vite 与 NativeScript
前端
zhedream38 分钟前
从模糊到清晰:一次组件重构里的开发哲学
vue.js
前端Hardy42 分钟前
GitHub 爆火!Three.js + React + ECharts 打造最强数据大屏
前端·javascript
如果超人不会飞43 分钟前
TinyRobot AI 对话组件库全组件使用指南
前端·vue.js
lichenyang4531 小时前
ArkTS 资源与暗色模式:为什么我手机切暗色,App 内容区却不变
前端