1
我使用vue組件來顯示註釋以及對註釋的回覆。要顯示答覆,我只是簡單地使用評論組件遞歸。但是,我收到一個錯誤。Vue中的遞歸組件js
這裏是我的代碼
<template>
<div class="box">
<article class="media">
<figure class="media-left">
<p class="image is-64x64">
<img :src="comment.channel.data.imageUrl">
</p>
</figure>
<div class="media-content">
<div class="content">
<p>
<strong><a :href="channelUrl">{{ comment.channel.data.name }}</a></strong> <small>{{ comment.created_at_human }}</small>
<br>
<p class="is-medium">{{ comment.body }}</p>
<nav class="level is-mobile">
<div class="level-left">
<a class="level-item">
<span class="icon is-small"><i class="fa fa-comment-o"></i></span>
</a>
</div>
</nav>
</p>
</div>
</div>
</article>
<comment v-for="reply in comment.replies.data" :comment="reply" :key="reply.id"></comment>
</div>
我收到以下錯誤:
[Vue warn]: Error in render function: "TypeError: Cannot read property 'data' of undefined"
found in
---> <Reply> at /home/vagrant/Laravel/youtube/resources/assets/js/components/Comment.vue... (1 recursive calls)
<VideoComments> at /home/vagrant/Laravel/youtube/resources/assets/js/components/VideoComments.vue
<VideoPlayerLayout> at /home/vagrant/Laravel/youtube/resources/assets/js/components/VideoPlayerLayout.vue
<Root>
數據是可用的對象,我使用分形生成JSON輸出。不知道我錯在哪裏。