title: vuejs - How to show the number of likes for each post
body: <p><strong>My Home.vue file:</strong></p>
  
  <pre><code>&lt;template&gt;
      &lt;div&gt;
          &lt;my-post
              v-for="(post, index) in posts"
              :post="post"
              :index="index"
              :key="post.id"
          &gt;&lt;/my-post&gt;
      &lt;/div&gt;
  &lt;/template&gt;
  
  &lt;script&gt;
      import Post from './Post.vue';
  
      export default {
          data() {
              return {
                  posts: []
              }
          },
          mounted() {
              axios.get('http://localhost/mine/test')
                  .then(response =&gt; {
                      this.posts = response.data.posts;
                  })
                  .catch(error =&gt; {
                      // console.log(error);
                  })
          },
          components: {'my-post': Post}
      }
  &lt;/script&gt;
  </code></pre>
  
  <p><strong>My Post.vue file:</strong></p>
  
  <pre><code>&lt;template&gt;
      &lt;div class="post"&gt;
          &lt;!-- The content of the post...
          I want to count the number of likes for each post here something like this:
          &lt;p&gt;{{likes.length}}&lt;/p&gt; --&gt;
      &lt;/div&gt;
  &lt;/template&gt;
  
  &lt;script&gt;
      export default {
          props: ['post'],
          data() {
              return {}
          }
      }
  &lt;/script&gt;
  </code></pre>
  
  <p>The data that is got by <code>axios.get('http://localhost/mine/test')</code> is like this:</p>
  
  <pre><code>posts: Array [
      {0:first_name:'example123',post_id:1},
      {1:first_name:'example456',post_id:2},
      {2:first_name:'example789',post_id:3},
  ],
  likes: Array [
      {0:first_name:'example1',post_id:1},
      {1:first_name:'example2',post_id:1},
      {2:first_name:'example3',post_id:1},
  ]
  </code></pre>
  
  <p>Note that they are separate. The likes are not the children of posts.</p>
  
  <p>I set likes in props as posts but the issue is that it shows the number of likes exactly the same.</p>
  
  <p>How can I get the number of likes for each post?</p>
  
  <p>Thanks</p>