未捕获(在承诺中)TypeError:无法读取未定义的属性(读取“地址”)
2022-06-05
23432
我的组件出现错误。有人能帮忙解决这个问题吗? 我在使用 vue 3 版本。 出现错误: “未捕获(在承诺中)TypeError:无法读取未定义的属性(读取“地址”)” 有人有什么见解吗? profile.vue
<template>
<div>
<div class="col col-lg-12 col-xl-12" v-for="(_postData, index) in postData" v-
bind:key="index">
<h1>{{ _postData.id.address }}</h1>
</div>
</div>
</template>
script
data() {
return {
postData: {},
postPagination: {
filter_data: [],
page_no: 1,
limit: 5
}
}
},
getPost() {
try {
CreatorService.getAllMedia(this.postPagination)
.then((response) => {
if (response.status === true) {
this.postData = response.data
}
})
.catch((error) => {
this.isPostLoading = false
this.errorLog(error)
})
} catch (e) {
this.errorTryLog(e)
}
}
response
[
{
"id": 1,
"name": "Leanne Graham",
"username": "Bret",
"email": "[email protected]",
"address": {
"street": "Kulas Light",
"suite": "Apt. 556",
"city": "Gwenborough",
"zipcode": "92998-3874",
"geo": {
"lat": "-37.3159",
"lng": "81.1496"
}
},
"phone": "1-770-736-8031 x56442",
"website": "hildegard.org",
"company": {
"name": "Romaguera-Crona",
"catchPhrase": "Multi-layered client-server neural-net",
"bs": "harness real-time e-markets"
}
}
]
1个回答
而不是
_postdata.id.address
尝试
_postdata.address
。代码> 022962335
Rohìt Jíndal
2022-06-05