Dynamic routes with parameters

Vue router easily allows you to have dynamic URLs. A dynamic URL allows you to use the same component to display different data while using the same template. An example of this would be for a shop, where all the category pages look the same but display different data based on the URL. Another example would be a product detail page—you don't want to have to create a component for every product, so instead, you use one component with a URL parameter.

URL parameters can appear anywhere in the path, and there can be one or many. Each parameter gets assigned a key, so it can be created and accessed consistently. We'll go into dynamic routes and parameters in more detail during the Chapter 9, Using Vue-Router Dynamic ...

Get Vue.js 2.x by Example now with the O’Reilly learning platform.

O’Reilly members experience books, live events, courses curated by job role, and more from O’Reilly and nearly 200 top publishers.