Skip to content

Commit

Permalink
feature: add pathToRegexp to compile path (#1148)
Browse files Browse the repository at this point in the history
  • Loading branch information
PanJiaChen committed Oct 8, 2018
1 parent f563857 commit 6488686
Show file tree
Hide file tree
Showing 2 changed files with 11 additions and 1 deletion.
1 change: 1 addition & 0 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -95,6 +95,7 @@
"node-sass": "^4.7.2",
"optimize-css-assets-webpack-plugin": "5.0.0",
"ora": "3.0.0",
"path-to-regexp": "2.4.0",
"portfinder": "1.0.13",
"postcss-import": "11.1.0",
"postcss-loader": "2.1.6",
Expand Down
11 changes: 10 additions & 1 deletion src/components/Breadcrumb/index.vue
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,7 @@

<script>
import { generateTitle } from '@/utils/i18n'
import pathToRegexp from 'path-to-regexp'
export default {
data() {
Expand All @@ -29,7 +30,15 @@ export default {
methods: {
generateTitle,
getBreadcrumb() {
let matched = this.$route.matched.filter(item => item.name)
const { params } = this.$route
let matched = this.$route.matched.filter(item => {
if (item.name) {
// To solve this problem https://github.com/PanJiaChen/vue-element-admin/issues/561
var toPath = pathToRegexp.compile(item.path)
item.path = toPath(params)
return true
}
})
const first = matched[0]
if (first && first.name.trim().toLocaleLowerCase() !== 'Dashboard'.toLocaleLowerCase()) {
matched = [{ path: '/dashboard', meta: { title: 'dashboard' }}].concat(matched)
Expand Down

0 comments on commit 6488686

Please sign in to comment.