Skip to content

Commit 8dcf9e2

Browse files
committed
feat: pass current route params into breadcrumb function
1 parent 59a545f commit 8dcf9e2

File tree

2 files changed

+12
-1
lines changed

2 files changed

+12
-1
lines changed

readme.md

Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -45,6 +45,7 @@ Vue.use(VueRouter);
4545
Vue.use(VueBreadcrumbs);
4646

4747
const Feeds = {template: '<div><router-view/></div>'};
48+
const Feed = {template: '<div><h2>Feed</h2></div>'};
4849
const Biz = {template: '<div><h2>Biz</h2></div>'};
4950
const Foo = {template: '<div><h2>Foo</h2></div>'};
5051
const Bar = {template: '<div><h2>Bar</h2></div>'};
@@ -76,6 +77,13 @@ const router = new VueRouter({
7677
meta: {
7778
breadcrumb: 'bar'
7879
}
80+
},
81+
{
82+
path: ':id',
83+
component: Feed,
84+
meta: {
85+
breadcrumb: (routeParams) => `Other Feed ${routeParams.id}`
86+
}
7987
}
8088
]
8189
}
@@ -92,6 +100,9 @@ new Vue({
92100
<div class="dropdown-menu">
93101
<router-link to="/feeds/foo" class="dropdown-item">Foo</router-link>
94102
<router-link to="/feeds/bar" class="dropdown-item">Bar</router-link>
103+
<router-link to="/feeds/1" class="dropdown-item">Other Feed 1</router-link>
104+
<router-link to="/feeds/2" class="dropdown-item">Other Feed 2</router-link>
105+
<router-link to="/feeds/3" class="dropdown-item">Other Feed 3</router-link>
95106
</div>
96107
</li>
97108
</ul>

src/vue-2-breadcrumbs.js

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -20,7 +20,7 @@ export default {
2020
Vue.component('breadcrumbs', {
2121
methods: {
2222
getBreadcrumb: function (bc) {
23-
return typeof bc === 'function' ? bc() : bc
23+
return typeof bc === 'function' ? bc(this.$route.params) : bc
2424
}
2525
},
2626
template: `

0 commit comments

Comments
 (0)