vue實現(xiàn)動態(tài)面包屑導(dǎo)航
更新時間:2022年04月13日 10:54:05 作者:風(fēng)如也
這篇文章主要為大家詳細介紹了vue實現(xiàn)動態(tài)面包屑導(dǎo)航的使用方法,文中示例代碼介紹的非常詳細,具有一定的參考價值,感興趣的小伙伴們可以參考一下
本文實例為大家分享了vue實現(xiàn)動態(tài)面包屑導(dǎo)航的具體代碼,供大家參考,具體內(nèi)容如下
動態(tài)面包屑導(dǎo)航是根據(jù)路由中的matched
獲取到的
單獨提取出面包屑導(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: '首頁' } }].concat(matched) ? ? ? ? this.levelList = matched ? ? ? } else { ? ? ? ? this.levelList = [{ path: '/index', meta: { title: '首頁' } }] ? ? ? } ? ? }, ? ? 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" />
以上就是本文的全部內(nèi)容,希望對大家的學(xué)習(xí)有所幫助,也希望大家多多支持腳本之家。
相關(guān)文章
Vue Cli 3項目使用融云IM實現(xiàn)聊天功能的方法
這篇文章主要介紹了Vue Cli 3項目 使用融云IM實現(xiàn)聊天功能,本文通過實例代碼給大家介紹的非常詳細,具有一定的參考借鑒價值,需要的朋友可以參考下2019-04-04利用Vue+intro.js實現(xiàn)頁面新手引導(dǎo)流程功能
在同學(xué)們使用某些網(wǎng)站的新版本頁面的時候,經(jīng)常會出現(xiàn)一個類似于新手引導(dǎo)一樣的效果,來幫助同學(xué)們更好的熟悉新版本頁面的功能和使用,這篇文章主要給大家介紹了關(guān)于如何利用Vue+intro.js實現(xiàn)頁面新手引導(dǎo)流程功能的相關(guān)資料,需要的朋友可以參考下2023-11-11vue實現(xiàn)下拉框的多選功能(附后端處理參數(shù))
本文介紹了如何使用Vue實現(xiàn)下拉框的多選功能,實現(xiàn)了在選擇框中選擇多個選項的功能,文章詳細介紹了實現(xiàn)步驟和示例代碼,對于想要了解如何使用Vue實現(xiàn)下拉框多選功能的讀者具有一定的參考價值2023-08-08