Skip to content

Commit b28b02f

Browse files
committed
Added dynamic route and history mode
1 parent f7cb384 commit b28b02f

File tree

4 files changed

+15
-5
lines changed

4 files changed

+15
-5
lines changed

src/App.vue

-1
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,6 @@
22
<div id="app">
33
<div id="nav">
44
<router-link :to="{ name: 'event-list' }">List</router-link> |
5-
<router-link :to="{ name: 'event-show' }">Show Event #1</router-link> |
65
<router-link :to="{ name: 'event-create' }">Create</router-link>
76
</div>
87
<router-view/>

src/router.js

+4-2
Original file line numberDiff line numberDiff line change
@@ -7,16 +7,18 @@ import EventShow from './views/EventShow.vue'
77
Vue.use(Router)
88

99
export default new Router({
10+
mode: 'history',
1011
routes: [
1112
{
1213
path: '/',
1314
name: 'event-list',
1415
component: EventList
1516
},
1617
{
17-
path: '/event',
18+
path: '/event/:id',
1819
name: 'event-show',
19-
component: EventShow
20+
component: EventShow,
21+
props: true
2022
},
2123
{
2224
path: '/event/create',

src/views/EventList.vue

+5-1
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,7 @@
11
<template>
2-
<h1>Events Listing</h1>
2+
<div>
3+
<h1>Events Listing</h1>
4+
5+
<router-link :to="{ name: 'event-show', params: { id: '1' } }">Show Event #1</router-link>
6+
</div>
37
</template>

src/views/EventShow.vue

+6-1
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,8 @@
11
<template>
2-
<h1>Showing event #1</h1>
2+
<h1>Showing event #{{ id }}</h1>
33
</template>
4+
<script>
5+
export default {
6+
props: ['id']
7+
}
8+
</script>

0 commit comments

Comments
 (0)