嗨,我剛剛開始使用 VueJs,但同時(shí)遇到了困難。 我正在開發(fā)一個(gè) Laravel + VueJs 項(xiàng)目,并且在博客和評(píng)論系統(tǒng)中工作。 對此,我創(chuàng)建了一個(gè)評(píng)論表,其中有 “respond_to_id” 屬性,該屬性將存儲(chǔ)父評(píng)論的“id”。 然后在 VueJs 級(jí)別我檢索這些父級(jí)和子級(jí)評(píng)論。 但問題出在 VueJs 顯示上。由于我只回復(fù)子評(píng)論,因此最后一條評(píng)論不會(huì)顯示在該子評(píng)論下方。
這是我用于檢索子評(píng)論的 Vue.Js 代碼。
<div v-for="(commentaire, i) in commentaires" :key="i" v-if="commentaires.length" > <div id="comment-1" class="comment"> <div class="d-flex"> <div class="comment-img"> <img v-bind:src="commentaire.photo" alt="" /> </div> <div> <h5> <a href="">{{ commentaire.name }}</a> <a @click="repondre(commentaire)" class="reply" ><i class="bi bi-reply-fill"></i> répondre</a > </h5> <time datetime="2020-01-01" >il y a {{ format(commentaire.created_at) }}</time > <p> {{ commentaire.contenu }} </p> </div> </div> </div> <!-- End comment #1 --> <div id="comment-reply-1" class="comment comment-reply" v-for="child in commentaire.children" :key="child.id" v-bind:commentaire="child" > <div class="d-flex"> <div class="comment-img"> <img v-bind:src="child.photo" alt="" /> </div> <div> <h5> <a href="">{{ child.name }}</a> <a @click="repondre(child)" class="reply" ><i class="bi bi-reply-fill"></i> répondre</a > </h5> <time datetime="2020-01-01">{{ format(child.created_at) }}</time> <p> {{ child.contenu }} </p> </div> </div> <!-- End comment reply #2--> </div> </div>
我想知道錯(cuò)誤出在哪里。請幫助我。
問題是,當(dāng)我回復(fù)子評(píng)論時(shí),我的評(píng)論沒有顯示在子評(píng)論下方。