Express 引导模式不';无法显示正确的post\u id

Express 引导模式不';无法显示正确的post\u id,express,bootstrap-4,ejs,Express,Bootstrap 4,Ejs,当我在一个对象数组上循环时,我试图访问代码开头给出的post_id。我在每一点上甚至在模型内部发布post.post_id。问题:显示的post\u id与给定的post是正确的,直到post.post\u id位于模式内。。。然后,它会显示最近一篇文章的post.post_id,而不是正确的post.post_id。。。下面是我的代码:引导模式会改变post.post_id的值,有什么原因吗?我似乎找不到我正在犯的错误 [这是我遇到的问题的一个例子,post ID在达到模式之前都很好]

当我在一个对象数组上循环时,我试图访问代码开头给出的post_id。我在每一点上甚至在模型内部发布post.post_id。问题:显示的post\u id与给定的post是正确的,直到post.post\u id位于模式内。。。然后,它会显示最近一篇文章的post.post_id,而不是正确的post.post_id。。。下面是我的代码:引导模式会改变post.post_id的值,有什么原因吗?我似乎找不到我正在犯的错误

[这是我遇到的问题的一个例子,post ID在达到模式之前都很好]

        <%- include ('./partials/header.ejs') %>

        <h3 class="greeting">Hi <%=username%>, check out what others are posting:) </h3>



        <% for (let post of allPosts) { %>



        <div class="postBox">
            first <%=post.post_id%>

            <div class="postHead">
                <a id="username" href="/<%=post.username%>"><%=post.username%></a>
                second  <%=post.post_id%>
            </div>

            <div class="postBody">
                third  <%=post.post_id%>
                <a href="/posts/<%=post.username%>/<%=post.post_id%>"><img
                    id="postImage" src="<%=post.image%>" alt="<%=post.image%>">
                </a>
                <% if (allLikes.includes(post.post_id)) { %>

                    <form class=""
                    action="/action/unlike/<%=post.username%>/<%=post.post_id%>?"
                    method="POST">
                        <button type="submit" name="button"
                        class="unlike-button"><ion-icon name="heart-dislike"></ion-icon></button>
                    </form>
                <% } else { %>
                    <form class=""
                    action="/action/like/<%=post.username%>/<%=post.post_id%>?"
                    method="POST">

                        <button type="submit" name="button"><ion-icon class="like-button" name="heart-outline"></ion-icon></button>

                    </form>
                <% } %>
            </div>
            <div class="postDescription">
                 fourth <%=post.post_id%>
                 <!-- Button trigger modal -->
                 <button type="button" data-bs-toggle="modal" data-bs-target="#exampleModal">
                   post_id: <%=post.post_id%>
                 </button>

                 <!-- Modal -->
                 <div class="modal fade" id="exampleModal" tabindex="-1" aria-labelledby="exampleModalLabel" aria-hidden="true">
                   <div class="modal-dialog">
                     <div class="modal-content">
                       <div class="modal-header">
                         <h5 class="modal-title" id="exampleModalLabel">Modal title</h5>
                         <button type="button" class="btn-close" data-bs-dismiss="modal" aria-label="Close"></button>
                       </div>
                       <div class="modal-body">
                         post_id: <%=post.post_id%>
                       </div>
                       <div class="modal-footer">
                         <button type="button" class="btn btn-secondary" data-bs-dismiss="modal">Close <%=post.post_id%></button>
                         <button type="button" class="btn btn-primary">Save changes</button>
                       </div>
                     </div>
                   </div>
                 </div>






                <div class="mainDescription">
                    <a id="username" href="/<%=post.username%>"><%=post.username%></a> <%=post.description%>
                    <%=post.post_id%>
                </div>

            </div>

            <br>
            <% for (let comment of allComments) { %>
                <% if (comment.post_id === post.post_id) { %>
                    <p><a id="username" href="/<%= comment.username%>"><%= comment.username%></a> <%=comment.comment%></p>
                <% } %>
            <% } %>


            <form action="/comments/<%=post.post_id%>" method="POST">
                <input class="commentBox" type="text" name="comment" placeholder="Add a comment...">
            </form>
        </div>
        <% } %>



    </body>```


  [1]: https://i.stack.imgur.com/zugIX.png

您好,请查看其他人发布的内容:)
第一
第二
第三
第四
邮政编码:
情态标题
邮政编码:
接近
保存更改

``` [1]: https://i.stack.imgur.com/zugIX.png