Skip to content

Commit 093153c

Browse files
committed
fix(breadcrumb): fix pathCompile and navigationDuplicated
1 parent f8bda6a commit 093153c

File tree

2 files changed

+8
-4
lines changed

2 files changed

+8
-4
lines changed

.gitignore

+2
Original file line numberDiff line numberDiff line change
@@ -18,6 +18,8 @@ yarn-error.log*
1818
# Editor directories and files
1919
.idea
2020
.vscode
21+
.history
22+
.ionide
2123
*.suo
2224
*.ntvs*
2325
*.njsproj

src/components/Breadcrumb/index.vue

+6-4
Original file line numberDiff line numberDiff line change
@@ -22,7 +22,7 @@
2222
</template>
2323

2424
<script lang="ts">
25-
import pathToRegexp from 'path-to-regexp'
25+
import { compile } from 'path-to-regexp'
2626
import { Component, Vue, Watch } from 'vue-property-decorator'
2727
import { RouteRecord, Route } from 'vue-router'
2828
@@ -67,17 +67,19 @@ export default class extends Vue {
6767
private pathCompile(path: string) {
6868
// To solve this problem https://github.com/PanJiaChen/vue-element-admin/issues/561
6969
const { params } = this.$route
70-
const toPath = pathToRegexp.compile(path)
70+
const toPath = compile(path)
7171
return toPath(params)
7272
}
7373
7474
private handleLink(item: any) {
75+
// Throw Error "NavigationDuplicated"
76+
// https://github.com/vuejs/vue-router/issues/2872
7577
const { redirect, path } = item
7678
if (redirect) {
77-
this.$router.push(redirect)
79+
this.$router.push(redirect).catch(_err => {})
7880
return
7981
}
80-
this.$router.push(this.pathCompile(path))
82+
this.$router.push(this.pathCompile(path)).catch(_err => {})
8183
}
8284
}
8385
</script>

0 commit comments

Comments
 (0)