2017-12-09 14 views
1

私のJSONデータは、私がデータ[]の外にある「評価」以外のすべての詳細を表示することができていますvue jsの評価の値を表示する方法は?

{"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); 
} 
} 
}); 
}, 
}) 
+0

のですか? – Psidom

+0

サー、私は、jsonデータの最後にある評価以外のすべてのデータを印刷することができます – med

+0

おそらく 'rating'ですか?あなたのvueコンポーネントはどのように定義されていますか? – Psidom

答えて

1

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>
`reviews`が定義されてどのように

関連する問題