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

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

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

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

在這里插入圖片描述

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

接下來(lái)打印一下選中項(xiàng)index和index路徑,

在這里插入圖片描述

刷新也是沒(méi)有任何問(wèn)題的,active不會(huì)消失,整體代碼如下:

<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高亮消失的問(wèn)題的文章就介紹到這了,更多相關(guān)Vue3刷新后active高亮消失內(nèi)容請(qǐng)搜索腳本之家以前的文章或繼續(xù)瀏覽下面的相關(guān)文章希望大家以后多多支持腳本之家!

相關(guān)文章

最新評(píng)論