Reputation: 33
I want to use the URL params and Queries into the vue router defining file in order to set the title name dynamically.
I tried to use the $route.params.paramName
format:
const routes = [
{
path: '/rooms/:room/:id?',
name: `${$route.params.room}`,
component: RoomsView,
meta:{
title: `${$route.params.room} ${$route.params.id} - WebsiteName`
}
}
]
Do you know how can I access these values?
Upvotes: 0
Views: 127
Reputation: 336
I think it's best to let the component itself render the logic with something like
computed: {
title() {
const { name, id } = this.$route.params;
return `${name} ${id} - WebsiteName`;
}
}
I think the docs would give you some useful insight as well
Upvotes: 1