Nuxt/examples/nested-routes/pages/index/_id.vue

35 lines
591 B
Vue
Raw Normal View History

2017-01-26 14:22:10 +00:00
<template>
<div class="player">
<h1>#{{ number }}</h1>
<h2>{{ name }}</h2>
</div>
</template>
<script>
export default {
2017-10-31 13:43:55 +00:00
validate({ params }) {
2017-01-26 14:22:10 +00:00
return !isNaN(+params.id)
},
2017-10-31 13:43:55 +00:00
asyncData({ params, env, error }) {
2017-01-26 14:22:10 +00:00
const user = env.users.find((user) => String(user.id) === params.id)
if (!user) {
return error({ message: 'User not found', statusCode: 404 })
}
return user
2017-08-01 12:16:04 +00:00
},
2017-10-31 13:43:55 +00:00
head() {
2017-08-01 12:16:04 +00:00
return {
title: this.name
}
2017-01-26 14:22:10 +00:00
}
}
</script>
<style scoped>
.player {
text-align: center;
margin-top: 100px;
font-family: sans-serif;
}
</style>