Skip to content

Commit

Permalink
fix: previous crumb link wrong, close #43
Browse files Browse the repository at this point in the history
  • Loading branch information
Scrum committed Jul 18, 2018
1 parent 8f02a94 commit 8e9454e
Show file tree
Hide file tree
Showing 2 changed files with 11 additions and 7 deletions.
2 changes: 1 addition & 1 deletion .editorconfig
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@ charset = utf-8
trim_trailing_whitespace = true
insert_final_newline = true

[*.{json,yml,jade,pss,css,html}]
[*.{json,yml,jade,pss,css,html,js}]
indent_size = 2

[*.html]
Expand Down
16 changes: 10 additions & 6 deletions src/vue-2-breadcrumbs.js
Original file line number Diff line number Diff line change
Expand Up @@ -3,16 +3,20 @@ export default {
Object.defineProperties(Vue.prototype, {
$breadcrumbs: {
get() {
return this.$route.matched.map(r => {
let path = '';
let route = r;
const breadcrumbs = this.$route.matched.map(routeRecord => {
let path = routeRecord.path;
let route = routeRecord;

Object.keys(this.$route.params).forEach(e => {
path = route.path.replace(':' + e, this.$route.params[e]);
Object.keys(this.$route.params).forEach(param => {
path = route.path.replace(':' + param, this.$route.params[param]);
}, this);

route.path = path;

return route;
}, this);

return breadcrumbs;
}
}
});
Expand All @@ -29,7 +33,7 @@ export default {
<router-link active-class="active" :to="{ path: crumb.path }" :tag="i != $breadcrumbs.length - 1 ? 'a' : 'span'">{{ getBreadcrumb(crumb.meta.breadcrumb) }}</router-link>
</li>
</ol>
`
`
});
}
};

0 comments on commit 8e9454e

Please sign in to comment.