添加一个 "Load More" 按钮以在 Vue 中添加来自 WordPress API 的下 4 篇文章

Adding a "Load More" button to add next 4 posts from WordPress API in Vue

我正在尝试添加一个加载更多按钮,每次单击它时都会显示接下来的 4 个帖子(然后在没有更多帖子时消失或变为非活动状态)来自 WordPress API Vue,但我似乎无法让它正常工作。

这是我目前的代码:

<template>
  <div class="videos">
    <div class="inner grid">
      <div class="video" v-for="video in videos" :key="video.id">
        <div class="video-info-pane">
          <div class="video-img" :style="{ backgroundImage: 'url(' + video.acf.video_poster + ')' }">
            <div class="mask"></div>
                        <i class="fa fa-play"></i>            
          </div>
          <div class="video-info-pane-title">
            <h3 class="video-title">
              <router-link :to="{ name: 'videos', params: { id: video.slug }}">
                <strong v-html="video.title.rendered"></strong>
              </router-link>
            </h3>
            <div class="video-info-pane-title-inner">
              <router-link :to="{ name: 'games', params: { id: video.acf.game[0].post_name }}">
                <img :title="video.acf.game[0].post_title" class="slide-info-img" :src="video.acf.game_icon">
              </router-link>
              <div class="video-details">
                <span class="second video-date">{{video.formatted_date}}</span>
                <span class="second video-length">{{video.acf.video_length}}</span>
              </div>
              <router-link :to="{ name: 'videos', params: { id: video.slug }}" class="video-link">
                <strong>Details &rarr;</strong>
              </router-link>
            </div>
          </div>  
        </div>    
      </div>
    </div>
    <button @click="addMoreVideos" class="btn">Load More</button>
  </div>  
</template>

<script> 
  import axios from "axios"
  export default{
    name: 'Videos',
    data() {
      return {
        videosUrl: 'https://robertsfrontend.com/games/wp-json/wp/v2/videos?_embed',
        queryOptions: {
          per_page: 4,
          page: 1,
          offset: 1,
          _embed: true
        },
        videos: [],
      }
    },
    methods: {
      getRecentVideos() {
        axios
          .get(this.videosUrl, { params: this.queryOptions })
          .then(response => {
            this.videos = response.data;
          })
      },
      addMoreVideos: function() {
        this.queryOptions += 4
        this.getRecentVideos();
      }      
    },
    mounted() {
      this.getRecentVideos();
    }
  }
</script>

在添加更多视频中:this.queryOptions.per_page += 4;