mirror of
https://github.com/nuxt/nuxt.git
synced 2024-11-30 09:27:13 +00:00
Update custom route example
Build and Router
This commit is contained in:
parent
0b8b85128f
commit
8870c181d7
@ -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']
|
||||||
|
5
examples/custom-routes/pages/comments/_id.vue
Normal file
5
examples/custom-routes/pages/comments/_id.vue
Normal file
@ -0,0 +1,5 @@
|
|||||||
|
<template>
|
||||||
|
<div>
|
||||||
|
Comments by Id
|
||||||
|
</div>
|
||||||
|
</template>
|
5
examples/custom-routes/pages/comments/index.vue
Normal file
5
examples/custom-routes/pages/comments/index.vue
Normal file
@ -0,0 +1,5 @@
|
|||||||
|
<template>
|
||||||
|
<div>
|
||||||
|
Comments list
|
||||||
|
</div>
|
||||||
|
</template>
|
@ -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>
|
||||||
|
|
||||||
|
6
examples/custom-routes/pages/post.vue
Normal file
6
examples/custom-routes/pages/post.vue
Normal file
@ -0,0 +1,6 @@
|
|||||||
|
<template>
|
||||||
|
<div>
|
||||||
|
Post Layout
|
||||||
|
<router-view></router-view>
|
||||||
|
</div>
|
||||||
|
</template>
|
5
examples/custom-routes/pages/post/_slug.vue
Normal file
5
examples/custom-routes/pages/post/_slug.vue
Normal file
@ -0,0 +1,5 @@
|
|||||||
|
<template>
|
||||||
|
<div>
|
||||||
|
Post : slug
|
||||||
|
</div>
|
||||||
|
</template>
|
6
examples/custom-routes/pages/three.vue
Normal file
6
examples/custom-routes/pages/three.vue
Normal file
@ -0,0 +1,6 @@
|
|||||||
|
<template>
|
||||||
|
<div>
|
||||||
|
Layout Three
|
||||||
|
<router-view></router-view>
|
||||||
|
</div>
|
||||||
|
</template>
|
6
examples/custom-routes/pages/three/_two.vue
Normal file
6
examples/custom-routes/pages/three/_two.vue
Normal file
@ -0,0 +1,6 @@
|
|||||||
|
<template>
|
||||||
|
<div>
|
||||||
|
Layout Two
|
||||||
|
<router-view></router-view>
|
||||||
|
</div>
|
||||||
|
</template>
|
5
examples/custom-routes/pages/three/_two/index.vue
Normal file
5
examples/custom-routes/pages/three/_two/index.vue
Normal file
@ -0,0 +1,5 @@
|
|||||||
|
<template>
|
||||||
|
<div>
|
||||||
|
Layout Two Index
|
||||||
|
</div>
|
||||||
|
</template>
|
6
examples/custom-routes/pages/three/_two/one.vue
Normal file
6
examples/custom-routes/pages/three/_two/one.vue
Normal file
@ -0,0 +1,6 @@
|
|||||||
|
<template>
|
||||||
|
<div>
|
||||||
|
Layout One
|
||||||
|
<router-view></router-view>
|
||||||
|
</div>
|
||||||
|
</template>
|
5
examples/custom-routes/pages/three/_two/one/_id.vue
Normal file
5
examples/custom-routes/pages/three/_two/one/_id.vue
Normal file
@ -0,0 +1,5 @@
|
|||||||
|
<template>
|
||||||
|
<div>
|
||||||
|
Layout One with Id
|
||||||
|
</div>
|
||||||
|
</template>
|
Loading…
Reference in New Issue
Block a user