设置router-link样式-使用a

设置样式图一变成图二

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

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

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

完整代码

<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>

相关推荐

  1. Vue关于router-link使用和部分代码

    2024-04-22 23:18:04       49 阅读
  2. yarn link使用(npm link)

    2024-04-22 23:18:04       59 阅读
  3. PyQt5 使用setStyleSheet设置控件的样式

    2024-04-22 23:18:04       32 阅读
  4. Vue自定义组件中使用CSS变量设置样式

    2024-04-22 23:18:04       43 阅读

最近更新

  1. docker php8.1+nginx base 镜像 dockerfile 配置

    2024-04-22 23:18:04       98 阅读
  2. Could not load dynamic library ‘cudart64_100.dll‘

    2024-04-22 23:18:04       106 阅读
  3. 在Django里面运行非项目文件

    2024-04-22 23:18:04       87 阅读
  4. Python语言-面向对象

    2024-04-22 23:18:04       96 阅读

热门阅读

  1. js 数组去重的6种方法

    2024-04-22 23:18:04       34 阅读
  2. LeetCode刷题--- 完全平方数

    2024-04-22 23:18:04       35 阅读
  3. Rust---泛型(Generics)

    2024-04-22 23:18:04       32 阅读
  4. git 代码仓库

    2024-04-22 23:18:04       35 阅读
  5. 如何将本地项目上传到gitlab

    2024-04-22 23:18:04       40 阅读
  6. 【Spring】@Scheduled 定时器注解使用

    2024-04-22 23:18:04       40 阅读
  7. iOS知识点 ---- 离屏渲染

    2024-04-22 23:18:04       35 阅读
  8. CentOS常见命令详解

    2024-04-22 23:18:04       40 阅读
  9. vueelementui+tabs选项卡样式更改-内容待递增

    2024-04-22 23:18:04       35 阅读
  10. 安卓平台下OkHttp3网络库的全面探讨与实践

    2024-04-22 23:18:04       37 阅读
  11. python selenium 获取伪类

    2024-04-22 23:18:04       39 阅读
  12. SCP收容物081~09

    2024-04-22 23:18:04       36 阅读