vuejs / vuex-router-sync

Effortlessly keep vue-router and vuex store in sync.
MIT License
2.52k stars 125 forks source link

store.route doesn't contain the `matched` property #63

Closed danieldiekmeier closed 7 years ago

danieldiekmeier commented 7 years ago

I noticed that the matched property doesn't exist on the cloned route that gets sent to the store.

I wanted to create a getter that basically merges all the meta fields, so I can access if from the templates:

export function meta (state) {
  return state.route.matched.reduce((prev, match) => {
    return Object.assign({}, prev, match.meta)
  }, {})
}

At the moment, it doesn't work. Could this be added, or are there reasons for the current behaviour?

A little bit related to #31.

yyx990803 commented 7 years ago

The problem is that matched may contain arbitrary values from the route configuration AND potentially component instances. These are not safely serializable when the devtool is taking snapshots and can lead to inconsistent behavior when you use time-travel debugging, persistence or snapshot exports.