-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathapp.vue
46 lines (41 loc) · 964 Bytes
/
app.vue
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
<script lang="ts" setup>
// -----------------------------------
// test case 1: bug
// -----------------------------------
const { data } = await useAsyncData(async () => {
const coreObject = ref({
nestText: 'success',
});
const wrappar = ref({
coreObject,
});
return {
wrappar,
};
});
if (!data.value) {
throw new Error('data is undefined');
}
// value: success
// console error: TypeError: Cannot read properties of undefined (reading 'coreObject')
console.log(data.value.wrappar.coreObject.nestText);
// value: undefined
// no console error
console.log(data.value.wrappar.value.coreObject.nestText);
// -----------------------------------
// test case 2: success
// -----------------------------------
const coreObject = ref({
nestText: 'success',
});
const wrappar = ref({
coreObject,
});
// value: success
console.log(wrappar.value.coreObject.nestText);
</script>
<template>
<div>
<NuxtWelcome />
</div>
</template>