I'm faced with the challenge of creating a dynamic title for a Vue route. Unfortunately, I haven't been able to figure out how to pass a parameter into the meta title. This is crucial for me because my VueHeader
component relies on the route meta title to render a heading. Here's the snippet of code I've been working with:
{
path: '/case/:id',
name: 'edit-case',
component: VueEditCase,
meta: {
title: 'Edit case ' + $route.params.id,
},
},
However, every attempt I make results in an error message stating
Uncaught ReferenceError: $route is not defined
. The issue persists regardless of whether I try title: 'Edit case ' + this.$route.params.id
, title: 'Edit case ' + route.params.id
, or title: 'Edit case ' + this.route.params.id
. I've even experimented with title: 'Edit case ' + ':id'
, but nothing seems to work.
After scouring the internet for a solution without success, I thought I'd turn to you all for help. Has anyone encountered a similar problem and managed to find a resolution?
Here are screenshots of some other routes that are functioning properly: https://i.sstatic.net/bbdDy.png
And here's a visual representation of how I am rendering the meta title in the header: https://i.sstatic.net/CWl96.png
Below are screenshots showing how the header appears when navigating to the example routes mentioned above: https://i.sstatic.net/xxvrB.png https://i.sstatic.net/yTOYl.png