Vue中ElementUI后台管理系统面包屑el-breadcrumb

47 篇文章 0 订阅
12 篇文章 0 订阅

html

<template>
    <div class="myTitle">
        <div class="img">
            <!-- <img src="../../assets/LOOG.png" alt=""> -->
            LOOG
            <div class="breadcrumb">
                <el-breadcrumb separator="/">
                    <el-breadcrumb-item :to="{ path: '/' }">首页</el-breadcrumb-item>
                    <el-breadcrumb-item :to="{path: breadList.path}">
                        {{breadList.meta.title}}
                    </el-breadcrumb-item>
                </el-breadcrumb>
            </div>
        </div>
    </div>
</template>

<script>
export default {
    data () {
        return {
            breadList: [] // 路由集合
        };
    },
    watch: {
        $route () {
            this.getBreadcrumb();
        }
    },
    created(){
         this.getBreadcrumb();
    },
    methods: {
        getBreadcrumb(){
            console.log(this.$route.matched[1],'this.$route.matched;');
            this.breadList = this.$route.matched[1]
        }
    }
}
</script>

<style lang="scss" scoped>
.myTitle {
    width: 100%;
    height: 72px;
    display: flex;
    align-items: center;
    border-bottom: 1px solid #e0e0e0;
    .img {
        margin-left: 110px;
    }
    .breadcrumb {
        display: flex;
    }
}
</style>

router

import Vue from 'vue'
import VueRouter from 'vue-router'
import Home from '../views/Home.vue'
import Esercise from '../views/esercise.vue'




Vue.use(VueRouter)
// 导入admin子路由
import ChainManagement from '@/views/Home/chainManagement';
import TokenManagement from '@/views/Home/tokenManagement';
import VuePdf from '@/views/Home/vuePdf';



const routes = [{
        path: '/',
        redirect: '/'
    },
    {
        path: '/',
        name: 'Home',
        component: Home,
        children: [{
                path: '/chainManagement',
                component: ChainManagement,
                meta: {
                    title: '链管理'
                }
            },
            {
                path: '/tokenManagement',
                component: TokenManagement,
                meta: {
                    title: '代币管理'
                }
            },
            {
                path: '/vuePdf',
                name: 'VuePdf',
                component: VuePdf,
                meta: {
                    title: 'Pdf管理'
                }
            },
        ],

    },
    {
        path: '/about',
        name: 'About',
        // route level code-splitting
        // this generates a separate chunk (about.[hash].js) for this route
        // which is lazy-loaded when the route is visited.
        component: () => import( /* webpackChunkName: "about" */ '../views/About.vue')
    }, {
        path: '/esercise',
        name: 'Esercise',
        component: Esercise,
    }
]

const router = new VueRouter({
    mode: 'history',
    base: process.env.BASE_URL,
    routes
})

export default router

效果

在这里插入图片描述

参考

博主1
博主2
博主3

最后

感觉文章好的话记得点个心心和关注和收藏,有错的地方麻烦指正一下,如果需要转载,请标明出处,多谢!!!

  • 0
    点赞
  • 3
    收藏
    觉得还不错? 一键收藏
  • 0
    评论
Vue 的 UI 框架 Element UI 提供了面包屑组件 el-breadcrumb,可以方便地实现面包屑导航功能。同时,Element UI 也提供了国际化的支持,可以让我们方便地实现面包屑的国际化。 以下是在 Vue 项目使用 el-breadcrumb 组件实现面包屑导航的代码: ```vue <template> <div> <el-breadcrumb separator="/"> <el-breadcrumb-item :to="{ path: '/' }">{{ $t('home') }}</el-breadcrumb-item> <el-breadcrumb-item :to="{ path: '/list' }">{{ $t('list') }}</el-breadcrumb-item> <el-breadcrumb-item>{{ $t('detail') }}</el-breadcrumb-item> </el-breadcrumb> </div> </template> <script> export default { name: 'BreadcrumbDemo', data() { return {}; }, }; </script> ``` 在上面的代码,我们使用 el-breadcrumb 组件来包含多个 el-breadcrumb-item 组件,每个 el-breadcrumb-item 组件代表一个面包屑导航项,可以通过 :to 属性设置跳转链接。 接下来,我们实现面包屑导航的国际化。在 Vue 项目使用 Element UI 的国际化需要先引入 Element UI 的语言包,然后在 Vue 的配置选项设置语言包和翻译函数。以下是实现面包屑导航国际化的代码: ```javascript import Vue from 'vue'; import ElementUI from 'element-ui'; import locale from 'element-ui/lib/locale/lang/en'; // 引入英文语言包 Vue.use(ElementUI, { locale }); Vue.prototype.$t = function(key) { return this.$i18n.t(key); }; new Vue({ i18n, render: h => h(App), }).$mount('#app'); ``` 在上面的代码,我们引入了 Element UI 的英文语言包,并在 Vue 配置选项设置语言包和翻译函数。之后,我们就可以在 el-breadcrumb-item 组件使用 $t 函数来进行国际化翻译了。我们只需要在翻译文件添加相应的翻译内容即可,例如: ```javascript { "home": "Home", "list": "List", "detail": "Detail" } ``` 这样,我们就成功地实现了 el-breadcrumb 面包屑面包屑国际化功能。

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值