vue實(shí)現(xiàn)動(dòng)態(tài)面包屑導(dǎo)航
本文實(shí)例為大家分享了vue實(shí)現(xiàn)動(dòng)態(tài)面包屑導(dǎo)航的具體代碼,供大家參考,具體內(nèi)容如下
動(dòng)態(tài)面包屑導(dǎo)航是根據(jù)路由中的matched獲取到的
單獨(dú)提取出面包屑導(dǎo)航欄組件
<template>
? <el-breadcrumb class="app-breadcrumb" separator="/">
? ? <transition-group name="breadcrumb">
? ? ? <el-breadcrumb-item v-for="item in levelList" :key="item.path" :to="{ path: item.path }">
? ? ? ? <span>{{ item.meta.title }}</span>
? ? ? </el-breadcrumb-item>
? ? </transition-group>
? </el-breadcrumb>
</template>
<script>
export default {
? data () {
? ? return {
? ? ? levelList: null
? ? }
? },
? watch: {
? ? $route () {
? ? ? this.getBreadcrumb()
? ? }
? },
? created() {
? ? this.getBreadcrumb()
? },
? methods: {
? ? getBreadcrumb () {
? ? ? let matched = this.$route.matched.filter(item => item.meta && item.meta.title)
? ? ? const first = matched[0]
? ? ? if (!this.isIndex(first)) {
? ? ? ? matched = [{ path: '/index', meta: { title: '首頁(yè)' } }].concat(matched)
? ? ? ? this.levelList = matched
? ? ? } else {
? ? ? ? this.levelList = [{ path: '/index', meta: { title: '首頁(yè)' } }]
? ? ? }
? ? },
? ? isIndex (route) {
? ? ? const redirect = route && route.redirect
? ? ? if (!redirect) {
? ? ? ? return false
? ? ? }
? ? ? return redirect === '/index'
? ? }
? },
}
</script>
<style lang="scss">
/* breadcrumb transition */
.breadcrumb-enter-active,
.breadcrumb-leave-active {
? transition: all .5s;
}
.breadcrumb-enter,
.breadcrumb-leave-active {
? opacity: 0;
? transform: translateX(20px);
}
.breadcrumb-move {
? transition: all .5s;
}
.breadcrumb-leave-active {
? position: absolute;
}
.app-breadcrumb.el-breadcrumb {
? margin-left: 8px;
}
</style>在布局組件中應(yīng)用
<!-- 面包屑 --> <dBreadcrumb class="breadcrumb-container" />

以上就是本文的全部?jī)?nèi)容,希望對(duì)大家的學(xué)習(xí)有所幫助,也希望大家多多支持腳本之家。
相關(guān)文章
Vue3 elementUI 中 date-picker 使用過(guò)程遇到坑
這篇文章主要介紹了Vue3 elementUI 中 date-picker 使用過(guò)程遇到坑,本文給大家介紹的非常詳細(xì),對(duì)大家的學(xué)習(xí)或工作具有一定的參考借鑒價(jià)值,需要的朋友參考下吧2023-10-10
Vue項(xiàng)目使用PostCSS做h5頁(yè)面的屏幕適配的配置步驟
PostCSS 是一個(gè)用 JavaScript 編寫(xiě)的工具,用于將 CSS 轉(zhuǎn)換為另一種 CSS,在做h5頁(yè)面的屏幕適配時(shí),結(jié)合 PostCSS 的一些插件能輕松實(shí)現(xiàn),下面以結(jié)合 postcss-pxtorem 插件為例,詳細(xì)介紹配置步驟,需要的朋友可以參考下2025-02-02
Vue 實(shí)現(xiàn)簡(jiǎn)易多行滾動(dòng)"彈幕"效果
這篇文章主要介紹了Vue 實(shí)現(xiàn)簡(jiǎn)易多行滾動(dòng)“彈幕”效果,本文通過(guò)實(shí)例代碼給大家介紹的非常詳細(xì),具有一定的參考借鑒價(jià)值,需要的朋友可以參考下2020-01-01
Vue后臺(tái)實(shí)現(xiàn)點(diǎn)擊圖片放大功能的示例代碼
這篇文章主要為大家詳細(xì)介紹了如何利用Vue實(shí)現(xiàn)點(diǎn)擊圖片放大功能,文中的示例代碼講解詳細(xì),具有一定的借鑒價(jià)值,需要的可以參考一下2022-12-12
Vue3?響應(yīng)式系統(tǒng)實(shí)現(xiàn)?computed
這篇文章主要介紹了?Vue3?響應(yīng)式系統(tǒng)實(shí)現(xiàn)?computed,文章圍繞主題展開(kāi)詳細(xì)的內(nèi)容介紹,具有一定的參考價(jià)值,感興趣的小伙伴可以參考一下2022-06-06
vue3+vite+移動(dòng)端webview打包后頁(yè)面加載空白問(wèn)題解決辦法
這篇文章主要給大家介紹了關(guān)于vue3+vite+移動(dòng)端webview打包后頁(yè)面加載空白問(wèn)題的解決辦法,文中通過(guò)代碼介紹的非常詳細(xì),對(duì)大家的學(xué)習(xí)或者工作具有一定的參考借鑒價(jià)值,需要的朋友可以參考下2024-06-06
vue中渲染對(duì)象中屬性時(shí)顯示未定義的解決
這篇文章主要介紹了vue中渲染對(duì)象中屬性時(shí)顯示未定義的解決,具有很好的參考價(jià)值,希望對(duì)大家有所幫助。一起跟隨小編過(guò)來(lái)看看吧2020-07-07

