英文:
how can i access this json in vuejs
问题
这是我的JSON
{
"Response": {
"Error": {
"ErrorCode": 0,
"ErrorMessage": ""
},
"Results": {
"FareBreakdown": [{
"Currency": "INR"
}
],
"FareRules": [{
"Origin": "DEL"
}]
}
}
}
这是我的脚本
const response = await axios.post(
"http://localhost:5000/api/fare-quote",
requestData
);
this.searchResult = response.data.Response.FareBreakdown;
console.log(this.searchResult)
我在控制台中得到了"undefined"
这是我在模板中使用来显示数据的方式
{{searchResult}}
我得到了一个良好的响应,但我只是尝试在我的模板中显示数据。
英文:
this is my json
{
"Response": {
"Error": {
"ErrorCode": 0,
"ErrorMessage": ""
},
"Results": {
"FareBreakdown": [{
"Currency": "INR"
}
],
"FareRules": [{
"Origin": "DEL"
}]
}
}
}
this my script
const response = await axios.post(
"http://localhost:5000/api/fare-quote",
requestData
);
this.searchResul = response.data.Response.FareBreakdown;
console.log(this.searchResul)
i get undefined in my console
this how i use in my template to show the data
{{searchResul}}
i get a good response but i'm just trying to display the data in my template
答案1
得分: 2
以下是已翻译的内容:
this.searchResul = response.data.Response.Results.FareBreakdown;
然后在你的模板中:
<li v-for="item in searchResul" :key="item.Currency">
货币: {{ item.Currency }}
</li>
英文:
do these
this.searchResul = response.data.Response.Results.FareBreakdown;
then in your template
<li v-for="item in searchResul" :key="item.Currency">
Currency: {{ item.Currency }}
</li>
通过集体智慧和协作来改善编程学习和解决问题的方式。致力于成为全球开发者共同参与的知识库,让每个人都能够通过互相帮助和分享经验来进步。
评论