Update custom route example

Build and Router
This commit is contained in:
Alexandre Chopin 2016-12-11 02:44:40 +01:00
parent 0b8b85128f
commit 8870c181d7
12 changed files with 79 additions and 12 deletions

View File

@ -1,8 +1,26 @@
module.exports = { module.exports = {
router: { router: {
routes: [ // routes: [
{ name: 'user', path: '/users/:id(\\d+)', component: 'pages/_user' } // { name: 'post-slug', path: ':slug(\\d+)' }
] // ],
routes: {
comments: {
_id: {
regexp: ':id(\\d+)',
generate: [1, 2, 3, 4] // Need to be finished on generate
}
},
three: {
_two: {
regexp: ':two(\\d+)',
one: {
_id: {
regexp: ':id(\\d+)'
}
}
}
}
}
}, },
build: { build: {
vendor: ['axios'] vendor: ['axios']

View File

@ -0,0 +1,5 @@
<template>
<div>
Comments by Id
</div>
</template>

View File

@ -0,0 +1,5 @@
<template>
<div>
Comments list
</div>
</template>

View File

@ -2,23 +2,23 @@
<div class="container"> <div class="container">
<h2>Users</h2> <h2>Users</h2>
<ul class="users"> <ul class="users">
<li v-for="user in users"> <!-- <li v-for="user in users">
<router-link :to="{ name: 'user', params: { id: user.id } }">{{ user.name }}</router-link> <router-link :to="{ name: 'user', params: { id: user.id } }">{{ user.name }}</router-link>
</li> </li> -->
</ul> </ul>
</div> </div>
</template> </template>
<script> <script>
import axios from 'axios' // import axios from 'axios'
export default { export default {
data () { // data () {
return axios.get('https://jsonplaceholder.typicode.com/users') // return axios.get('https://jsonplaceholder.typicode.com/users')
.then((res) => { // .then((res) => {
return { users: res.data } // return { users: res.data }
}) // })
} // }
} }
</script> </script>

View File

@ -0,0 +1,6 @@
<template>
<div>
Post Layout
<router-view></router-view>
</div>
</template>

View File

@ -0,0 +1,5 @@
<template>
<div>
Post : slug
</div>
</template>

View File

@ -0,0 +1,6 @@
<template>
<div>
Layout Three
<router-view></router-view>
</div>
</template>

View File

@ -0,0 +1,6 @@
<template>
<div>
Layout Two
<router-view></router-view>
</div>
</template>

View File

@ -0,0 +1,5 @@
<template>
<div>
Layout Two Index
</div>
</template>

View File

@ -0,0 +1,6 @@
<template>
<div>
Layout One
<router-view></router-view>
</div>
</template>

View File

@ -0,0 +1,5 @@
<template>
<div>
Layout One with Id
</div>
</template>