Skip to content

Commit c13b574

Browse files
committed
fix[Breadcurmb]: fixed pathCompile bug
1 parent 9df740b commit c13b574

File tree

1 file changed

+7
-5
lines changed

1 file changed

+7
-5
lines changed

src/components/Breadcrumb/index.vue

Lines changed: 7 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,7 @@
33
<transition-group name="breadcrumb">
44
<el-breadcrumb-item v-for="(item,index) in levelList" v-if="item.meta.title" :key="item.path">
55
<span v-if="item.redirect==='noredirect'||index==levelList.length-1" class="no-redirect">{{ generateTitle(item.meta.title) }}</span>
6-
<router-link v-else :to="item.redirect||item.path">{{ generateTitle(item.meta.title) }}</router-link>
6+
<router-link v-else :to="item.redirect||pathCompile(item.path)">{{ generateTitle(item.meta.title) }}</router-link>
77
</el-breadcrumb-item>
88
</transition-group>
99
</el-breadcrumb>
@@ -30,12 +30,8 @@ export default {
3030
methods: {
3131
generateTitle,
3232
getBreadcrumb() {
33-
const { params } = this.$route
3433
let matched = this.$route.matched.filter(item => {
3534
if (item.name) {
36-
// To solve this problem https://github.com/PanJiaChen/vue-element-admin/issues/561
37-
var toPath = pathToRegexp.compile(item.path)
38-
item.path = toPath(params)
3935
return true
4036
}
4137
})
@@ -44,6 +40,12 @@ export default {
4440
matched = [{ path: '/dashboard', meta: { title: 'dashboard' }}].concat(matched)
4541
}
4642
this.levelList = matched
43+
},
44+
pathCompile(path) {
45+
// To solve this problem https://github.com/PanJiaChen/vue-element-admin/issues/561
46+
const { params } = this.$route
47+
var toPath = pathToRegexp.compile(path)
48+
return toPath(params)
4749
}
4850
}
4951
}

0 commit comments

Comments
 (0)