小编Kev*_*iss的帖子

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)

vue.js

6
推荐指数
1
解决办法
2万
查看次数

标签 统计

vue.js ×1