Use asyncData into children test

This commit is contained in:
Sebastien Chopin 2017-08-25 12:24:39 +02:00
parent 3bf1cb90c4
commit cb8bc559b4
2 changed files with 36 additions and 2 deletions

View File

@ -1,6 +1,23 @@
<template>
<div>
<h1>I am the parent</h1>
<h1>I am the {{ name }}</h1>
<nuxt-child></nuxt-child>
</div>
</template>
<script>
export default {
async asyncData({ route }) {
const asyncData = {};
await new Promise((resolve, reject) => {
setTimeout(() => {
asyncData.name = 'parent'
resolve();
}, 100)
});
return asyncData;
}
}
</script>

View File

@ -1,3 +1,20 @@
<template>
<h2>Id={{ $route.params.id }}</h2>
<h2>Id={{ id }}</h2>
</template>
<script>
export default {
async asyncData({ route }) {
const asyncData = {};
await new Promise((resolve, reject) => {
setTimeout(() => {
asyncData.id = route.params.id;
resolve();
}, 50)
});
return asyncData;
}
}
</script>