本篇文章為大家展示了如何在vue中使用面包屑導航組件,內(nèi)容簡明扼要并且容易理解,絕對能使你眼前一亮,通過這篇文章的詳細介紹希望你能有所收獲。
在成都做網(wǎng)站、網(wǎng)站建設中從網(wǎng)站色彩、結構布局、欄目設置、關鍵詞群組等細微處著手,突出企業(yè)的產(chǎn)品/服務/品牌,幫助企業(yè)鎖定精準用戶,提高在線咨詢和轉(zhuǎn)化,使成都網(wǎng)站營銷成為有效果、有回報的無錫營銷推廣。成都創(chuàng)新互聯(lián)專業(yè)成都網(wǎng)站建設10余年了,客戶滿意度97.8%,歡迎成都創(chuàng)新互聯(lián)客戶聯(lián)系。
vue的面包屑導航組件
用來將其放到navbar中;
Breadcrumb/index.vue
<template> <el-breadcrumb class="app-breadcrumb" separator="/"> <transition-group> <el-breadcrumb-item v-for="(item,index) in levelList" :key="item.path" v-if="item.meta.title"> <span v-if='item.redirect==="noredirect"||index==levelList.length-1' class="no-redirect">{{item.meta.title}}</span> <router-link v-else :to="item.redirect||item.path">{{item.meta.title}}</router-link> </el-breadcrumb-item> </transition-group> </el-breadcrumb> </template> <script> export default { name: "idnex", data(){ return { levelList:null } }, created() { this.getBreadcrumb() }, watch:{ $route(){ this.getBreadcrumb() } }, methods:{ getBreadcrumb(){ let matched=this.$route.matched.filter(item=>item.name)//$route.matched 將會是一個包含從上到下的所有對象 (副本)。 const first=matched[0] if(first && first.name !=='dashboard'){//$route.name當前路由名稱 ;$route.redirectedFrom重定向來源的路由的名字 matched=[{ path: '/dashboard', meta: { title: 'dashboard' }}].concat(matched) } this.levelList=matched } } } </script> <style rel="stylesheet/scss" lang="scss" scoped> .app-breadcrumb.el-breadcrumb { display: inline-block; font-size: 14px; line-height: 50px; margin-left: 10px; .no-redirect { color: #97a8be; cursor: text; } } </style>
ps:下面在看下一段代碼Vue 面包屑導航
樣式采用的是element ui 中的面包屑設置的,
<template> <el-breadcrumb> <el-breadcrumb-item separator = '/' v-for = "(item,index) in breadlist" :key = 'index' :to="{path: item.path}">{{item.meta.CName}} </el-breadcrumb-item> </el-breadcrumb> </template> js部分 <script> export default { data(){ return { breadlist: '' } }, created() { this.getBread(); }, methods:{ getBread(){ this.breadlist = this.$route.matched; this.$route.matched.forEach((item,index)=>{ //先判斷父級路由是否是空字符串或者meta是否為首頁,直接復寫路徑到根路徑 item.meta.CName === '首頁' ? item.path = '/' : this.$route.path === item.path; }); } }, watch:{ $route(){ this.getBread(); } } } </script>
上述內(nèi)容就是如何在vue中使用面包屑導航組件,你們學到知識或技能了嗎?如果還想學到更多技能或者豐富自己的知識儲備,歡迎關注創(chuàng)新互聯(lián)行業(yè)資訊頻道。
分享文章:如何在vue中使用面包屑導航組件
文章鏈接:http://bm7419.com/article2/iioooc.html
成都網(wǎng)站建設公司_創(chuàng)新互聯(lián),為您提供自適應網(wǎng)站、全網(wǎng)營銷推廣、動態(tài)網(wǎng)站、標簽優(yōu)化、靜態(tài)網(wǎng)站、手機網(wǎng)站建設
聲明:本網(wǎng)站發(fā)布的內(nèi)容(圖片、視頻和文字)以用戶投稿、用戶轉(zhuǎn)載內(nèi)容為主,如果涉及侵權請盡快告知,我們將會在第一時間刪除。文章觀點不代表本網(wǎng)站立場,如需處理請聯(lián)系客服。電話:028-86922220;郵箱:631063699@qq.com。內(nèi)容未經(jīng)允許不得轉(zhuǎn)載,或轉(zhuǎn)載時需注明來源: 創(chuàng)新互聯(lián)