Home > other >  Element of object in object
Element of object in object

Time:05-18

(vuejs3 axios / nodejs prisma sql)

I want to get content of my comment but I cannot.

Can you help me please?

    <div >
    <div  v-for="post in posts" >
        <header >
            <div >
                {{ post.user.name }} {{ post.user.last_name }}
            </div>
            <div >
                créer le :{{ post.createdAt }}
            </div>
        </header>
        <div >
            <h2 >{{ post.title }}</h2>
            <p >
                {{ post.content }}
            </p>
            <p>
                
            </p>
            <img src=''  >
        </div>
        <div >
            <div >
                {{ post.comments.comment.content }}
            </div>
        </div>
    </div>
</div>

enter image description here

CodePudding user response:

There is no comment property inside comments as comments is an array, To get the comments content you can iterate that further inside post.

<div  v-for="comment in post.comments">
    {{ comment.content }}
</div>
  • Related