How it works…

There are two main parts of the code that contribute to creating the routes for the different dishes.

First, we registered a generic route using the colon syntax and assigned a name to it, which is as follows code:

{ path: '/menu/:id', name: 'menu', component: Menu }

This means that we can have a URL that ends in /menu/82, and the Menu component will be displayed with the $route.params.id variable set to 82. So, the following line should be changed as per the following:

<img :src="'http://lorempixel.com/200/200/food/' + $route.params.id">

The preceding line will be replaced by the following line in the rendered DOM:

<img src="'http://lorempixel.com/200/200/food/82">

Never mind the fact that there is no such image in real ...

Get Vue.js 2 Cookbook 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.