欧美bbbwbbbw肥妇,免费乱码人妻系列日韩,一级黄片

解決Vue3使用Element-Plus導(dǎo)航刷新后active高亮消失的問題

 更新時間:2023年08月07日 10:49:53   作者:鍵指江湖  
這篇文章主要給大家介紹了如何解決Vue3使用Element-Plus導(dǎo)航刷新后active高亮消失的問題,文中有相關(guān)的代碼講解,需要的朋友可以參考下

解決Vue3 使用Element-Plus導(dǎo)航刷新后active高亮消失的問題

在這里插入圖片描述

啟用路由模式會在激活導(dǎo)航時以 index 作為 path 進(jìn)行路由跳轉(zhuǎn) 使用 default-active 來設(shè)置加載時的激活項。

接下來打印一下選中項index和index路徑,

在這里插入圖片描述

刷新也是沒有任何問題的,active不會消失,整體代碼如下:

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

到此這篇關(guān)于解決Vue3使用Element-Plus導(dǎo)航刷新后active高亮消失的問題的文章就介紹到這了,更多相關(guān)Vue3刷新后active高亮消失內(nèi)容請搜索腳本之家以前的文章或繼續(xù)瀏覽下面的相關(guān)文章希望大家以后多多支持腳本之家!

相關(guān)文章

最新評論