What is dynamic route matching?
Sometimes it may be required to map routes to the same component based on a pattern. Let’s take a user component with the mapped URLs like /user/john/post/123 and /user/jack/post/235 using dynamic segments:
1 2 3 4 5 6 7 8 9 10 | const User = { template: '<div>User {{ $route.params.name }}, PostId: {{ route.params.postid }}</div>' } const router = new VueRouter({ routes: [ // dynamic segments start with a colon { path: '/user/:name/post/:postid', component: User } ] }) |
If you like this question & answer and want to contribute, then write your question & answer and email to freewebmentor[@]gmail.com. Your question and answer will appear on FreeWebMentor.com and help other developers.