繁体   English   中英

如何在Vue JS中显示评分值?

[英]How to display value of rating in vue js?

我的json数据是

{"status": true, "reviews": [{"review": "scdbgnhvgdbsr", "rating": 5, "by": "aravind", "pid": 8, "review_id": 1}, {"review": "helsocxdxvfbgfnhfgdf", "rating": 2, "by": "ab", "pid": 8, "review_id": 2}], "rating": 3.5}

我可以显示除data []之外的“评级”以外的所有详细信息。 如何显示评分。 在这里我需要显示等级= 3.5

<div id="feed"> <div v-for="row in reviews">{{row.review}} </div> </div>

我的Vue JS脚本是

 new Vue({ 
 el: '#feed' , 
 data: { 
 data: [], 
 reviews: [],
 pid: '{{pid}}',
 }, 
 mounted() { 
var self = this; 
 const data = {}
 data['pid'] = this.pid;
 $.ajax({ 
 url: "http://127.0.0.1:8000/api/post/reviews/", 
 data: data,
 type: "POST",
 dataType: "JSON", 
 success: function (e) { 
 if (e.status == 1) { 
  self.reviews = e.reviews;
  console.log(self.reviews);
}
}
});
},
})

 var obj = jQuery.parseJSON( '{"status": true, "reviews": [{"review": "scdbgnhvgdbsr", "rating": 5, "by": "aravind", "pid": 8, "review_id": 1}, {"review": "helsocxdxvfbgfnhfgdf", "rating": 2, "by": "ab", "pid": 8, "review_id": 2}], "rating": 3.5}' ); alert( obj.rating); 
 <script src="https://ajax.googleapis.com/ajax/libs/jquery/2.1.1/jquery.min.js"></script> 

暂无
暂无

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM