gpt4 book ai didi

javascript - 如何在vue js中显示评分值?

转载 作者:行者123 更新时间:2023-11-30 14:53:38 26 4
gpt4 key购买 nike

我的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}

我能够显示除数据 [] 之外的“评级”以外的所有详细信息。我怎样才能显示评级。这里我需要显示 RATING= 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>

关于javascript - 如何在vue js中显示评分值?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/47726290/

26 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com