1const Mobile = {
2 template: `<div><h1>Mobile: {{this.$route.params.model}}</h1>
3 <h2>Price: {{this.$route.params.price}} Rs.</h2></div>
4 `,
5}
6const DefautMobile = {
7 template: `<div><h1>Mobile: Nokia 1500</h1>
8 <h2>Price: 1500 Rs.</h2></div>`,
9}
10const error = {
11 template: `<div> No mobile to show </div>`,
12}
13const MobileStore = {
14 template: `<div><h1>Welcome to Mobile Store</h1>
15 <div><router-view></router-view></div></div>`,
16}
17
18const routes = [
19 {
20 path: '/',
21 component: MobileStore,
22 children: [
23 { path: '', component: error },
24 {
25 path: 'mobile/:model/:price',
26 component: Mobile,
27 },
28 { path: '*', component: DefautMobile },
29 ],
30 },
31]
32const router = new VueRouter({ routes, base: '/' })
33const vm = new Vue({ el: '#app', router })