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