Vue.js 数据:未定义

Kev*_*iss 6 vue.js

我是 Vue.js 的新手。

请给我建议。
我得到评论:未定义所以评论没有显示。xhr 为 200 是正常的。

谢谢谢谢谢谢谢谢谢谢谢谢

<template>
 <div>
  <ul class="media-list">
     <li class="media" v-for="comment in comments">
         {{ $comment.body }}            
     </li>
  </ul> 
</div>
</template>


<script>
 export default {
    data () {
        return {
            comments: []
        }
    },
    props: {
        postid: null
    },
    methods: {
        getComments () {
            this.$http.get('/blog/' + this.postid + '/comments').then((response) => {
                this.comments = response.json().data;
            });
        }
    },
    mounted () {
        this.getComments();
    }
}
Run Code Online (Sandbox Code Playgroud)

小智 0

this.comments = response.json().data;

console.log(this.comments) ;
Run Code Online (Sandbox Code Playgroud)

看看你得到了什么;你定义comments=Array;也许你会得到response.json().datais not a Array;