Introducing Vue-Router and Loading URL-Based Components Chapter 8
formattedName() {
return this.name.charAt(0).toUpperCase() + this.name.slice(1);
}
}
};
We can now create a new route within our router, which uses the same component without
the final variable. Don't forget to enable props for the new route too:
const router = new VueRouter({
routes: [
{
path: '/',
component: Home
},
{
path: '/about',
component: About
},
{
path: '/:name/user',
component: User,
props: true
},
{
path: '/:name/user/:emotion',
component: User,
props: true
}
],
linkActiveClass: 'active',
linkExactActiveClass: 'current'
});
Now, by visiting /sarah/user, we should be presented with text that declares sarah is
happy.