Nuxt/examples/async-data/pages/index.vue
2016-11-19 22:16:26 +01:00

30 lines
510 B
Vue

<template>
<div>
<p>{{ userAgent }}</p>
<p><router-link to="/post">See a post (http request / Ajax)</router-link></p>
</div>
</template>
<script>
export default {
data ({ req }, callback) {
setTimeout(function () {
// callback(err, data)
callback(null, {
userAgent: (req ? req.headers['user-agent'] : navigator.userAgent)
})
}, 100)
}
}
</script>
<style scoped>
p {
font-size: 20px;
text-align: center;
padding: 100px;
padding-bottom: 0;
}
</style>