mirror of
https://github.com/nuxt/nuxt.git
synced 2024-11-23 14:15:13 +00:00
Fix example for v1
This commit is contained in:
parent
b921191f91
commit
a869637615
@ -2,6 +2,5 @@ module.exports = {
|
||||
build: {
|
||||
vendor: ['axios']
|
||||
},
|
||||
css: ['~/assets/main.css'],
|
||||
loading: false
|
||||
css: ['~/assets/main.css']
|
||||
}
|
||||
|
@ -1,5 +1,5 @@
|
||||
<template>
|
||||
<div class="container" :key="page">
|
||||
<div class="container">
|
||||
<nuxt-link v-if="page > 1" :to="'?page=' + (page - 1)">< Prev</nuxt-link>
|
||||
<a v-else class="disabled">< Prev</a>
|
||||
<span>{{ page }}/{{ totalPages }}</span>
|
||||
@ -23,16 +23,14 @@ export default {
|
||||
if (!from) return 'slide-left'
|
||||
return +to.query.page < +from.query.page ? 'slide-right' : 'slide-left'
|
||||
},
|
||||
asyncData ({ query }) {
|
||||
async asyncData ({ query }) {
|
||||
const page = +query.page || 1
|
||||
return axios.get(`https://reqres.in/api/users?page=${page}`)
|
||||
.then((res) => {
|
||||
return {
|
||||
page: +res.data.page,
|
||||
totalPages: res.data.total_pages,
|
||||
users: res.data.data
|
||||
}
|
||||
})
|
||||
const { data } = await axios.get(`https://reqres.in/api/users?page=${page}`)
|
||||
return {
|
||||
page: +data.page,
|
||||
totalPages: data.total_pages,
|
||||
users: data.data
|
||||
}
|
||||
}
|
||||
}
|
||||
</script>
|
||||
|
Loading…
Reference in New Issue
Block a user