Soh*_*aee 6 javascript ajax jquery vue.js
我有一个Vue js应用程序.我通过ajax获得一个列表:
$.ajax({
method: 'POST',
dataType: 'json',
url: this.base_info.url + 'getavailability?token=' + this.token,
data: this.search_info,
success: function (list) {
this.results = list;
console.log(list);
}.bind(this)
});
Run Code Online (Sandbox Code Playgroud)
这是结果:
{
"success": "true",
"error": "false",
"items": [
{
"relation_id": "9961",
"recommendation_id": "1",
"combination_id": "3",
"total_fare": "5530000",
"quantity_adult": "1",
"totalfare_adult": "5,530,000",
"quantity_child": "0",
"totalfare_child": "0",
"quantity_infant": "0",
"totalfare_infant": "0",
"airlines_name": "Qatar Airways",
"airline_logo": "QR"
},
{
"relation_id": "9962",
"recommendation_id": "1",
"combination_id": "4",
"total_fare": "5530000",
"quantity_adult": "1",
"totalfare_adult": "5,530,000",
"quantity_child": "0",
"totalfare_child": "0",
"quantity_infant": "0",
"totalfare_infant": "0",
"airlines_name": "Qatar Airways",
"airline_logo": "QR"
},
]
}
Run Code Online (Sandbox Code Playgroud)
当我通过Vue js遍历结果时,它输出并在我的表中清空行.
<div v-for="item in results.items">
<span class="big db">{{item.total_fare}}</span>
</div>
Run Code Online (Sandbox Code Playgroud)
我不知道哪个部分有问题.
在您的成功处理程序中附加类似的项目
this.$set('results.items', list);
Run Code Online (Sandbox Code Playgroud)
这可能会强制使用摘要周期,如果最初未在数据中声明results.items,则会对其进行评估.