mirror of
https://github.com/nuxt/nuxt.git
synced 2025-01-30 15:22:39 +00:00
Use asyncData into children test
This commit is contained in:
parent
3bf1cb90c4
commit
cb8bc559b4
19
test/fixtures/children/pages/parent.vue
vendored
19
test/fixtures/children/pages/parent.vue
vendored
@ -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>
|
||||
|
19
test/fixtures/children/pages/parent/_id.vue
vendored
19
test/fixtures/children/pages/parent/_id.vue
vendored
@ -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>
|
||||
|
Loading…
Reference in New Issue
Block a user