After exploring this documentation: https://router.vuejs.org/en/essentials/navigation.html
It seems that you can bind the
<router-link :to="variableName">Link Text</routerlink>
, which is quite useful. However, I've encountered some challenges trying to access route parameters within a component I am developing.
My approach involves using:
<router-link :to="permalink">Title of thing</router-link>
To direct the router view to retrieve the forum thread. In the router file:
import ForumThread from './views/groupTitle/forumThreadSingle';
// Other routes...
let routes = [
{
path: '/groupTitle/th/:id',
component: ForumThread,
}
];
Although in the forumthread component, $route.params.id is passed to it, when I try to access it like this:
console.log('The id is: ' + $route.params.id);
The object fails to locate the params section.
Both VueJS and JavaScript are relatively new to me. The examples I've come across demonstrate inline templates with the router file, something I'm attempting to avoid for code readability and cleanliness.
What modifications should I consider to successfully pass properties to the template file?
Thank you!