1//we can configure the routes to receive data via the url
2//first configure the route so it can receive data:
3
4const routes=[
5.
6.
7{path : '/page/:id?', name='page', component: Page},
8.
9.
10
11//inside the Page component we can get the data:
12
13 name:'Page',
14 mounted(){
15 this.url_data=this.$route.params.id;
16 },
17 data(){
18 return{
19 url_data: null
20 };
21 }
22
23
24 //the data can be then used in the template section of the component
25 <h2> {{url_data}}</h2>
1// literal string path
2router.push('home')
3
4// object
5router.push({ path: 'home' })
6
7// named route
8router.push({ name: 'user', params: { userId: '123' } })
9
10// with query, resulting in /register?plan=private
11router.push({ path: 'register', query: { plan: 'private' } })
12