解决Vue3 使用Element-Plus导航刷新active高亮消失

解决Vue3 使用Element-Plus导航刷新后active高亮消失的问题

启用路由模式会在激活导航时以 index 作为 path 进行路由跳转 使用 default-active 来设置加载时的激活项。

接下来打印一下选中项index和index路径,

刷新也是没有任何问题的,active不会消失,整体代码如下:

javascript 复制代码
<template>
    <div class="header">
        <el-menu
                :router="true"
                :default-active="route.path"
                class="el-menu-demo"
                mode="horizontal"
                background-color="#545c64"
                text-color="#fff"
                active-text-color="#ffd04b"
                @select="handleSelect"
        >
            <el-menu-item index="/">Home</el-menu-item>
            <el-menu-item index="/about">About</el-menu-item>
            <el-menu-item index="/news">News</el-menu-item>
            <el-menu-item index="/product">Product</el-menu-item>
        </el-menu>
    </div>
</template>
<script setup lang="ts">
import {useRoute} from "vue-router";
const route=useRoute()
const handleSelect = (key: string, keyPath: string[]) => {
    console.log(key, keyPath)
}
</script>
相关推荐
小云小白12 小时前
若依-vue3 把深色版本改成天蓝色-含登录页
vue3·若依·天蓝色
曲幽1 天前
FastApiAdmin 后端接口开发好了,前端管理界面怎么调用与显示?
python·vue3·api·fastapi·web·ant design·view·menu·frontend
曲幽5 天前
我用了FastApiAdmin后,连夜把踩过的坑都整理出来了
redis·python·postgresql·vue3·fastapi·web·sqlalchemy·admin·fastapiadmin
Liu.7746 天前
vue3bug收录
vue3
小云小白15 天前
高性能 v-html 弹窗实现:Vue3 + Element Plus 最佳实践
vue3·弹窗·v-html
xun-ming15 天前
SpringBoot和Vue3实战阿里百炼大模型极简版
spring boot·ai·vue3·智能体·百炼大模型
哆啦A梦158816 天前
20, Springboot3+vue3实现前台轮播图和详情页的设计
javascript·数据库·spring boot·mybatis·vue3
小盼江16 天前
基于Springboot3+Vue3的协同过滤鲜花商城推荐系统
vue3·springboot3·鲜花商城
哆啦A梦158817 天前
11,Springboot3+vue3个人中心,修改密码
java·前端·javascript·数据库·vue3
哆啦A梦158817 天前
01, 前端vue3框架的快速搭建以及项目工程的讲解
前端·vue3·springboot