Skip to content

Commit c3d2636

Browse files
feat: plain span element for last item
1 parent 63f18ea commit c3d2636

File tree

1 file changed

+19
-10
lines changed

1 file changed

+19
-10
lines changed

src/index.ts

Lines changed: 19 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -154,6 +154,24 @@ class VueBreadcrumbs implements PluginObject<ComponentOptions<Vue>> {
154154
if (crumb?.meta?.breadcrumb) {
155155
const label = this.getBreadcrumb(crumb.meta.breadcrumb);
156156
if (label?.length > 0) {
157+
let item;
158+
if (index !== this.$breadcrumbs.length - 1) {
159+
item = createElement(
160+
'router-link',
161+
{
162+
props: {
163+
to: { path: this.getPath(crumb) },
164+
tag: 'a'
165+
}
166+
},
167+
` ${label}`
168+
);
169+
}
170+
else {
171+
item = createElement(
172+
'span', ` ${label}`
173+
);
174+
}
157175
return createElement(
158176
'li',
159177
{
@@ -165,16 +183,7 @@ class VueBreadcrumbs implements PluginObject<ComponentOptions<Vue>> {
165183
}
166184
},
167185
[
168-
createElement(
169-
'router-link',
170-
{
171-
props: {
172-
to: { path: this.getPath(crumb) },
173-
tag: index !== this.$breadcrumbs.length - 1 ? 'a' : 'span'
174-
}
175-
},
176-
` ${label}`
177-
)
186+
item
178187
]
179188
)
180189
}

0 commit comments

Comments
 (0)