欧美bbbwbbbw肥妇,免费乱码人妻系列日韩,一级黄片

uniapp中uni-load-more的使用方式

 更新時(shí)間:2024年05月24日 09:01:03   作者:第7個(gè)前端  
這篇文章主要介紹了uniapp中uni-load-more的使用方式,具有很好的參考價(jià)值,希望對(duì)大家有所幫助,如有錯(cuò)誤或未考慮完全的地方,望不吝賜教

uniapp中uni-load-more使用

1 引入uniloadmore

import uniLoadMore from '@/components/uni-load-more/uni-load-more.vue';
components: {uniLoadMore},

2 data中寫的內(nèi)容

reload: false,
status: 'more',
contentText: {
        contentdown: '上拉加載更多~',
        contentrefresh: '加載中',
        contentnomore: '我是有底線的~'
},

3 template里面寫的內(nèi)容

<uni-load-more :status="status" :icon-size="14" :content-text="contentText" v-if="dataList.length > 0" />

4 請(qǐng)求接口成功之后,判斷加載狀態(tài),處理數(shù)據(jù)

success: (result) => {
        this.totalCount = result.data.total
        if (result.data.total > 0) {
                const dataMap = result.data.list
                this.dataList = this.reload ? dataMap : this.dataList.concat(dataMap);
                this.reload = false;
        } else {
                this.dataList = [];
        }
        if (this.totalCount == this.dataList.length) {
                this.reload = false;
                this.status = 'noMore'
        }
}

5 監(jiān)控加載狀態(tài)

onReachBottom() {
        if (this.totalCount > this.dataList.length) {
                this.status = 'loading';
                setTimeout(() => {
                        this.pageNum++
                        this.getMonthTask();//執(zhí)行的方法
                }, 1000)//這里我是延遲一秒在加載方法有個(gè)loading效果,如果接口請(qǐng)求慢的話可以去掉
        } else { //停止加載
                this.status = 'noMore'
        }
},

uniapp - load-more觸底加載,下拉刷新

底部加載load-more(uni-ui組件)

三個(gè)狀態(tài):more、loading、nomore

  • 觸底事件:onReachBottom
  • 下拉刷新:onPullDownRefresh,停止下拉刷新uni.stopPullDownRefresh()
<template>
  <view>
    <!-- 底部加載,三個(gè)狀態(tài):more、loading、nomore -->
    <uni-load-more :status="status"></uni-load-more>
  </view>
</template>
 
<script>
export default {
  data() {
    return {
      data: null,
      status: 'more', //觸底加載狀態(tài)
      page: 1, //記錄當(dāng)前頁(yè)碼
    };
  },
  //觸底事件,請(qǐng)求數(shù)據(jù)、合并
  onReachBottom() {
    console.log('到底了到底了...');
    this.status = 'loading';
    this.getData(this.page + 1);
    this.page += 1;
  },
  //下拉刷新,請(qǐng)求第一頁(yè)
  onPullDownRefresh() {
    this.getData();
  },
  mounted() {
    this.getData();
  },
  methods: {
    getData(page = 1) {
      uni.request({
        url: 'https://xxxx.....',
        method: 'GET',
        data: { page: page },
        success: res => {
          console.log(res);
          //如果頁(yè)數(shù)>1,需要拼接返回的數(shù)據(jù)
          if (page > 1) {
            res.data.result = [...this.data.result, ...res.data.result];
          }
          this.data = res.data;
          uni.stopPullDownRefresh(); //拿到數(shù)據(jù)后,停止下拉刷新
        },
        fail: () => {},
        complete: () => {}
      });
    },
  },
};
</script>

總結(jié)

以上為個(gè)人經(jīng)驗(yàn),希望能給大家一個(gè)參考,也希望大家多多支持腳本之家。

相關(guān)文章

  • 通過Element ui往頁(yè)面上加一個(gè)分頁(yè)導(dǎo)航條的方法

    通過Element ui往頁(yè)面上加一個(gè)分頁(yè)導(dǎo)航條的方法

    這篇文章主要介紹了通過Element ui往頁(yè)面上加一個(gè)分頁(yè)導(dǎo)航條的方法,文中通過示例代碼介紹的非常詳細(xì),對(duì)大家的學(xué)習(xí)或者工作具有一定的參考學(xué)習(xí)價(jià)值,需要的朋友們下面隨著小編來一起學(xué)習(xí)學(xué)習(xí)吧
    2021-05-05
  • Vue2.0 v-for filter列表過濾功能的實(shí)現(xiàn)

    Vue2.0 v-for filter列表過濾功能的實(shí)現(xiàn)

    今天小編就為大家分享一篇Vue2.0 v-for filter列表過濾功能的實(shí)現(xiàn),具有很好的參考價(jià)值,希望對(duì)大家有所幫助。一起跟隨小編過來看看吧
    2018-09-09
  • Vue3 AST解析器-源碼解析

    Vue3 AST解析器-源碼解析

    這篇文章我們從 ast 生成時(shí)調(diào)用的 baseParse 函數(shù)分析,再到 baseParse 返回 createRoot 的調(diào)用結(jié)果,一直到細(xì)化的講解了 parseChildren 解析子節(jié)點(diǎn)函數(shù)中的其中某一個(gè)具體解析器的執(zhí)行過程。最后通過一個(gè)簡(jiǎn)單模板舉例,需要的朋友可以參考下
    2021-09-09
  • Vue2源碼解析之自定義指令

    Vue2源碼解析之自定義指令

    自定義指令,其實(shí)就是在vue提供的鉤子中寫代碼,這篇文章將從源碼的角度,帶大家深入了解一下Vue2種自定義指令的實(shí)現(xiàn)與使用,需要的可以參考一下
    2023-05-05
  • Vue3學(xué)習(xí)之事件處理詳解

    Vue3學(xué)習(xí)之事件處理詳解

    Vue事件處理是每個(gè)Vue項(xiàng)目的必要方面。 它用于捕獲用戶輸入,共享數(shù)據(jù)以及許多其他創(chuàng)造性方式。本文將通過簡(jiǎn)單的示例為大家講解了Vue3中事件處理的使用,需要的可以參考一下
    2022-12-12
  • element-ui如何取消el-table的hover狀態(tài)(取消高亮顯示)

    element-ui如何取消el-table的hover狀態(tài)(取消高亮顯示)

    在一個(gè)項(xiàng)目中需要對(duì)element-ui的table組件進(jìn)行一些樣式的修改,其中就包括對(duì)hover效果的處理,下面這篇文章主要給大家介紹了關(guān)于element-ui如何取消el-table的hover狀態(tài)(取消高亮顯示)的相關(guān)資料,需要的朋友可以參考下
    2022-11-11
  • vue3 component is 不顯示的問題及解決

    vue3 component is 不顯示的問題及解決

    這篇文章主要介紹了vue3 component is 不顯示的問題及解決,具有很好的參考價(jià)值,希望對(duì)大家有所幫助,如有錯(cuò)誤或未考慮完全的地方,望不吝賜教
    2024-03-03
  • vue-plugin-hiprint 詳細(xì)使用

    vue-plugin-hiprint 詳細(xì)使用

    這篇文章主要介紹了vue-plugin-hiprint 詳細(xì)使用說明,使用Vue.Draggable庫(kù)構(gòu)建可拖拽元素的示例,你可以根據(jù)具體需求和技術(shù)選型選擇適合的庫(kù)或方法來實(shí)現(xiàn)可拖拽元素的功能,需要的朋友可以參考下
    2023-08-08
  • vue3?tailwindcss的使用教程

    vue3?tailwindcss的使用教程

    Tailwind是由Adam Wathan領(lǐng)導(dǎo)的TailwindLabs開發(fā)的 CSS 框架,這篇文章主要介紹了vue3?tailwindcss的使用,需要的朋友可以參考下
    2023-08-08
  • vue3+pinia的快速入門使用教程

    vue3+pinia的快速入門使用教程

    Pinia是Vue的一個(gè)存儲(chǔ)庫(kù),它允許你跨組件/頁(yè)面共享狀態(tài),下面這篇文章主要給大家介紹了關(guān)于vue3+pinia的快速入門使用,文中通過實(shí)例代碼介紹的非常詳細(xì),需要的朋友可以參考下
    2022-07-07

最新評(píng)論