mirror of
https://github.com/nuxt/nuxt.git
synced 2024-11-23 06:05:11 +00:00
Update custom route example
Build and Router
This commit is contained in:
parent
0b8b85128f
commit
8870c181d7
@ -1,8 +1,26 @@
|
||||
module.exports = {
|
||||
router: {
|
||||
routes: [
|
||||
{ name: 'user', path: '/users/:id(\\d+)', component: 'pages/_user' }
|
||||
]
|
||||
// routes: [
|
||||
// { 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: {
|
||||
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">
|
||||
<h2>Users</h2>
|
||||
<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>
|
||||
</li>
|
||||
</li> -->
|
||||
</ul>
|
||||
</div>
|
||||
</template>
|
||||
|
||||
<script>
|
||||
import axios from 'axios'
|
||||
// import axios from 'axios'
|
||||
|
||||
export default {
|
||||
data () {
|
||||
return axios.get('https://jsonplaceholder.typicode.com/users')
|
||||
.then((res) => {
|
||||
return { users: res.data }
|
||||
})
|
||||
}
|
||||
// data () {
|
||||
// return axios.get('https://jsonplaceholder.typicode.com/users')
|
||||
// .then((res) => {
|
||||
// return { users: res.data }
|
||||
// })
|
||||
// }
|
||||
}
|
||||
</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