1- import { ComponentOptions , PluginObject , VueConstructor , VNode } from 'vue'
1+ import { ComponentOptions , PluginObject , VueConstructor , VNode } from 'vue'
22
33import { RouteRecord } from 'vue-router' ;
44
@@ -25,7 +25,7 @@ class VueBreadcrumbs implements PluginObject<ComponentOptions<Vue>> {
2525 let routeRecord : RouteRecord [ ] = [ route ] ;
2626
2727 if ( route . meta ?. breadcrumb ?. parent ) {
28- const matched = this . $router . resolve ( { name : route . meta . breadcrumb . parent } ) . route . matched
28+ const matched = this . $router . resolve ( { name : route . meta . breadcrumb . parent } ) . route . matched
2929
3030 routeRecord = [ ...matched , ...routeRecord ] ;
3131 }
@@ -56,7 +56,7 @@ class VueBreadcrumbs implements PluginObject<ComponentOptions<Vue>> {
5656 return name ;
5757 } ,
5858 getPath ( crumb : RouteRecord ) : string {
59- let { path} = crumb ;
59+ let { path } = crumb ;
6060
6161 for ( const [ key , value ] of Object . entries ( this . $route . params ) ) {
6262 path = path . replace ( `:${ key } ` , value ) ;
@@ -76,29 +76,33 @@ class VueBreadcrumbs implements PluginObject<ComponentOptions<Vue>> {
7676 } ,
7777 this . $breadcrumbs . map ( ( crumb : RouteRecord , index : number ) => {
7878 if ( crumb ?. meta ?. breadcrumb ) {
79- return createElement (
80- 'li' ,
81- {
82- class : {
83- 'breadcrumb-item' : true
84- } ,
85- props : {
86- key : index
87- }
88- } ,
89- [
90- createElement (
91- 'router-link' ,
92- {
93- props : {
94- to : { path : this . getPath ( crumb ) } ,
95- tag : index !== this . $breadcrumbs . length - 1 ? 'a' : 'span'
96- }
79+ let label = this . getBreadcrumb ( crumb . meta . breadcrumb ) ;
80+ if ( label !== '' ) {
81+
82+ return createElement (
83+ 'li' ,
84+ {
85+ class : {
86+ 'breadcrumb-item' : true
9787 } ,
98- ` ${ this . getBreadcrumb ( crumb . meta . breadcrumb ) } `
99- )
100- ]
101- )
88+ props : {
89+ key : index
90+ }
91+ } ,
92+ [
93+ createElement (
94+ 'router-link' ,
95+ {
96+ props : {
97+ to : { path : this . getPath ( crumb ) } ,
98+ tag : index !== this . $breadcrumbs . length - 1 ? 'a' : 'span'
99+ }
100+ } ,
101+ ` ${ label } `
102+ )
103+ ]
104+ )
105+ }
102106 }
103107
104108 return createElement ( ) ;
0 commit comments