feature: add pathToRegexp to compile path (#1148)
This commit is contained in:
parent
ff13ee1f27
commit
d1cceb69b7
|
@ -94,6 +94,7 @@
|
||||||
"node-sass": "^4.7.2",
|
"node-sass": "^4.7.2",
|
||||||
"optimize-css-assets-webpack-plugin": "5.0.0",
|
"optimize-css-assets-webpack-plugin": "5.0.0",
|
||||||
"ora": "3.0.0",
|
"ora": "3.0.0",
|
||||||
|
"path-to-regexp": "2.4.0",
|
||||||
"portfinder": "1.0.13",
|
"portfinder": "1.0.13",
|
||||||
"postcss-import": "11.1.0",
|
"postcss-import": "11.1.0",
|
||||||
"postcss-loader": "2.1.6",
|
"postcss-loader": "2.1.6",
|
||||||
|
|
|
@ -11,6 +11,7 @@
|
||||||
|
|
||||||
<script>
|
<script>
|
||||||
import { generateTitle } from '@/utils/i18n'
|
import { generateTitle } from '@/utils/i18n'
|
||||||
|
import pathToRegexp from 'path-to-regexp'
|
||||||
|
|
||||||
export default {
|
export default {
|
||||||
data() {
|
data() {
|
||||||
|
@ -29,7 +30,15 @@ export default {
|
||||||
methods: {
|
methods: {
|
||||||
generateTitle,
|
generateTitle,
|
||||||
getBreadcrumb() {
|
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]
|
const first = matched[0]
|
||||||
if (first && first.name.trim().toLocaleLowerCase() !== 'Dashboard'.toLocaleLowerCase()) {
|
if (first && first.name.trim().toLocaleLowerCase() !== 'Dashboard'.toLocaleLowerCase()) {
|
||||||
matched = [{ path: '/dashboard', meta: { title: 'dashboard' }}].concat(matched)
|
matched = [{ path: '/dashboard', meta: { title: 'dashboard' }}].concat(matched)
|
||||||
|
|
Loading…
Reference in New Issue