uniapp 触底 请求分页接口

<scroll-view @scrolltolower="scrollBottom">
   <product-list :goodspage="goodspage"></product-list>
</scroll-view>
scrollBottom() {
      console.log('scroll bottom')
      if (this.page.current < this.page.pages) {
        this.page.current++
        this.getProductList()
      }
    },
async getProductList() {
      const res = await this.$api.getProductList(
        {
          page: {
            current: this.page.current,
            size: this.page.size,
          },
        },
      )
      this.page.total = res.data.total
      this.page.pages = res.data.pages
      this.page.current = res.data.current
	  //把返回来的新数据添加到原有数组中
      this.goodspage = [...this.goodspage, ...res.data.records]
    },
mounted() {
    this.getProductList()
  },
posted @ 2024-01-24 15:45  躺尸的大笨鸟  阅读(98)  评论(0编辑  收藏  举报