I saw this issue about retrieving metadata per page (effectively accessing this.$route.matched[0].components.default.options
) but couldn't find any documentation as to why the key we're looking at on this.$route.matched[0].components
is called default
– and whether that's stable and I can rely on it.
I couldn't find anything in the vue-router
docs for this, though it briefly mentions that matched
is an array of Route Record
copies. Looking at my /.nuxt/router.js
file, I see this:
export function createRouter () {
return new Router({
mode: 'history',
base: '/',
linkActiveClass: 'nuxt-link-active',
linkExactActiveClass: 'nuxt-link-exact-active',
scrollBehavior,
routes: [
{
path: "/about",
component: _3b78a70e,
name: "about"
},
{
path: "/categories/:id?",
component: _77c04516,
name: "categories-id"
},
{
path: "/",
component: _5b3081d3,
name: "index"
}
],
fallback: false
})
}
Which isn't even setting a components option, much less one named default
.
The second part (and this is maybe more of a Vue specific question) is how can I rely on <component>.options
? I can't find any documentation anywhere (Vue, Nuxt, etc.) which states that this is an attribute that carries the user supplied options from Vue.component
. Is this a stable api?