-
Notifications
You must be signed in to change notification settings - Fork 27
Update breadcrumb value from component #1
Comments
If the article page is going to be the last item in the breadcrumbs, you could use the $breadcrumbs property, loop it and then append your data to the end. e.g.
|
Added breadcrumb setter, stuck on how to get the dom to update
Implemented in branch issue-1, but does not update the dom until a second navigation occurs, which obviously isn't ideal. I've tracked it down to a single line of code in the vue-router package Object.freeze() on the Router, commenting this out allows the dom to update freely, but obviously this isn't a viable fix. Wondering if there's another way to enable the reactive state? |
@samturrell probably with $set or Vue.set - described here: https://vuejs.org/guide/reactivity.html#Change-Detection-Caveats Same for arrays: https://vuejs.org/guide/list.html#Caveats |
Ok, I see what you mean. The problem is the same if you use $set. |
Some work i did on this a little while ago can be viewed here: https://github.com/samturrell/vue-breadcrumbs/blob/issue-1/src/index.js Basically it's leveraging the internal Vue.util.defineReactive helper to listen for changes, but only changes on second page load. |
Yes, I checked it out and am currently trying around with it, but also couldn't find a solution yet. |
I'm thinking about setting a 'breadcrumb' (computed?) property in the displayed component itself, but it seems like there is no link from the route to the actual component object. |
In my branch it's available as this.$breadcrumb (https://github.com/samturrell/vue-breadcrumbs/blob/issue-1/examples/index.js) |
Sure, I saw that, but you're still storing it in the route object (which is frozen) via the setter, not in the component object (which is not frozen). I'm more thinking about something like this (note the Plugin: Object.defineProperties(Vue.prototype, {
$breadcrumbs: {
get: function () {
var crumbs = [];
for (var i = 0; i < this.$route.matched.length; i++) {
if (componentObject.breadcrumbText) {
crumbs.push({route: this.$route.matched[i], text: componentObject.breadcrumbText});
}
}
return crumbs;
},
},
} In component: export default {
computed: {
breadcrumb () {
return this.foo.bar
}
}
} The problem is that I can't find a way to get PS: I'm |
Good way to achieve that is to support some form of simple DSL inside { breadcrumb: [ '$scope', 'title' ]}
// or
{ breadcrumb: ($scope) => $scope.title } This would allow to access router and other constructs as well, since router injected into component's instance as everything else. |
So? Is there any solution? |
Hey guys, i'll try to look into this again this weekend if i have some time. Otherwise I'm happy to accept a PR 😄 |
@samturrell Have you played with this? |
I've been looking into this for a couple of hours now. I've managed to sync up the data in the meta with a I somehow need to trigger a recalculation of the |
@asmaps Did you find a solution to this? |
@ChadTaljaardt no, but I'm also not using this package anymore. And also I'm not using breadcrumbs anymore |
Is it possible to update breadcrumb value from the component? For example when I go to article page, I want to show the title of the article in breadcrumb, not something general like "Article page".
The text was updated successfully, but these errors were encountered: