我是 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 ×1