日韩性视频-久久久蜜桃-www中文字幕-在线中文字幕av-亚洲欧美一区二区三区四区-撸久久-香蕉视频一区-久久无码精品丰满人妻-国产高潮av-激情福利社-日韩av网址大全-国产精品久久999-日本五十路在线-性欧美在线-久久99精品波多结衣一区-男女午夜免费视频-黑人极品ⅴideos精品欧美棵-人人妻人人澡人人爽精品欧美一区-日韩一区在线看-欧美a级在线免费观看

歡迎訪問 生活随笔!

生活随笔

當前位置: 首頁 > 前端技术 > vue >内容正文

vue

webpack+vue+mint-ui 实现上拉加载更多(Loadmore组件)

發(fā)布時間:2025/3/19 vue 33 豆豆
生活随笔 收集整理的這篇文章主要介紹了 webpack+vue+mint-ui 实现上拉加载更多(Loadmore组件) 小編覺得挺不錯的,現(xiàn)在分享給大家,幫大家做個參考.

因為業(yè)務(wù)的需要界面需要實現(xiàn)分頁的功能,所以我就研究了一下如何利用mint-ui自帶的loadmore組件實現(xiàn)上拉加載更多功能。
首先在文件中引入組件

import {Indicator, Loadmore} from 'mint-ui';

參考了一下組件中的一些參數(shù)

bottomMethod 是上拉刷新執(zhí)行的方法 bottomPullText 為 pull 時加載提示區(qū)域的文字 默認值為上拉刷新,一般我會定義為上拉加載更多 bottomAllLoaded 若為真,則 bottomMethod 不會被再次觸發(fā)

然后在HTML中寫法如下

<mt-loadmore :bottom-method="loadBottomUse":bottom-all-loaded="allUseLoad" :bottomPullText='bottomText'ref="loadmore"><div class="tab-list" v-for='item in useScoreLog'><div class="tab-list-top"><span class="tab-name">{{item.remark}}</span><span class="tab-num">{{item.score}}</span></div><div class="tab-list-bottom"><span class="tab-time">{{item.operateTime}}</span><span class="tab-class">{{item.recordTypeName}}</span></div></div></mt-loadmore>

js中寫法如下

首先在data的方法中定義初始化加載中的數(shù)組getScoreLog,當前頁數(shù)pageNo,是否加載allLoaded,上拉時加載的文字bottomText,初始化方法中的數(shù)量總數(shù)totalCount。

代碼如下

data(){return {getScoreLog: [],pageNo: 1,allLoaded: false,bottomText: '上拉加載更多...',totalCount: '',}},初始化方法如下getData(){this.$http.post(commonUrl + "/restful/", {typeFlag: '1'}).then(response => {if (response.data.errcode == 0) {this.getScoreLog = response.data.scoreLog;this.totalGetCount = (response.data.recordCount + 9) / 10;}}, response => {});},

下面便是上拉加載更多的方法

loadBottom() {this.pageNo += 1;if (this.pageNo == this.totalGetCount) {this.allLoaded = true;}setTimeout(() => {this.$http.post(commonUrl + "/restful/", {pageNo: this.pageNo,typeFlag: '1'}).then(response => {if (response.data.errcode == 0) {this.getScoreLog = this.getScoreLog.concat(response.data.scoreLog);}}, response => {});}, 1500);},

這樣就大功告成啦~

總結(jié)

以上是生活随笔為你收集整理的webpack+vue+mint-ui 实现上拉加载更多(Loadmore组件)的全部內(nèi)容,希望文章能夠幫你解決所遇到的問題。

如果覺得生活随笔網(wǎng)站內(nèi)容還不錯,歡迎將生活随笔推薦給好友。