当前位置:网站首页>Uniapp scrolling load (one page, multiple lists)
Uniapp scrolling load (one page, multiple lists)
2022-06-26 07:48:00 【GHUIJS】
Start with a picture , It's all made up in the back 

Global variables :
data() {
return {
tabIndex: 0,
faultTabarIndex: 0,
list: [],
listMax: 0,// The total number of data lists in the interface
showLoadMore: false,// Whether to display the bottom touch prompt
pageNo: 1,// Number of pages loaded
loadMoreText: ' Loading ...'// Load prompt text
}
},
Load list method , It's easy to understand , Is to change through globally defined identity , And then execute different requests :
getList() {
if (this.tabIndex === 0) {
this.$http.get('/agent/media/getWarnHouses', {
pageNo: this.pageNo,
pageSize: 5
}).then(_ => {
this.listMax = _.data.page.count;
_.data.page.list.forEach(item => {
this.list.push(item);
})
})
} else if (this.tabIndex === 1) {
this.$http.get('/agent/media/getBackFaults', {
status: this.faultTabarIndex + 1,
pageNo: this.pageNo,
pageSize: 5
}).then(_ => {
this.listMax = _.data.page.count;
_.data.page.list.forEach(item => {
this.list.push(item);
})
})
} else {
this.$http.get('/agent/media/getWareDelivery', {
pageNo: this.pageNo,
pageSize: 2
}).then(_ => {
this.listMax = _.data.page.count;
_.data.page.list.forEach(item => {
this.list.push(item);
})
})
}
},
Then when the global identity changes , Give Way
list: [],
listMax: 0,// The total number of data lists in the interface
showLoadMore: false,// Whether to display the bottom touch prompt
pageNo: 1,// Number of pages loaded
loadMoreText: ' Loading ...'// Load prompt text
Set as default ,
tabChange(index){
this.tabIndex = index;
this.loadMoreText = ' Loading ...';
this.pageNo = 1;
this.list = [];
this.showLoadMore = false;
if(index === 1){
this.faultTabarIndex = 0;
}
this.getList();
},
Finally, add uniapp The official page scrolls to the bottom of the life cycle , You need to determine whether the length of the page list is equal to the total number of data returned by the interface and change the prompt text . Then add one to the number of pages , Finally, call the get data method .
onReachBottom() {
this.showLoadMore = true;
if (this.list.length == this.listMax) {
this.loadMoreText = ' No more data !'
return;
}
++this.pageNo;
this.getList();
}Add prompt text under the list
<view class="uni-loadmore" v-if="showLoadMore">{
{loadMoreText}}</view>边栏推荐
- Deeply analyze storage costs and find cost reduction solutions
- [North Asia data recovery] a server data recovery method in which the partitions in the RAID5 array are formatted due to the misoperation of the NTFS file system
- ReW_ p
- 项目管理学习
- [NLP] vector retrieval model landing: Bottleneck and solution!
- WiFi-802.11 2.4G频段 5G频段 信道频率分配表
- D do not assign references to non domain parameters
- 技术分享 | MySQL:caching_sha2_password 快速问答
- Redis (4) -- Talking about integer set
- 指南针炒股软件开户是合法的吗?安全吗
猜你喜欢
![[recommend an entity class conversion tool mapstruct, which is powerful and easy to use]](/img/7b/43becce42192fb5e0469465aa27a36.png)
[recommend an entity class conversion tool mapstruct, which is powerful and easy to use]

WiFi-802.11 2.4G频段 5G频段 信道频率分配表

Apache InLong毕业成为顶级项目,具备百万亿级数据流处理能力!
![Jemter stress test - basic requirements - [teaching]](/img/f4/36dbd80e89d96e1121a6e2b92d1d07.png)
Jemter stress test - basic requirements - [teaching]

What is the difference between bone conduction earphones and ordinary earphones? Advantages of bone conduction earphones

Opencv鼠标事件+界面交互之绘制矩形多边形选取感兴趣区域ROI

What are the key points of turnover box management in warehouse management

Apache inlong graduated as a top-level project with a million billion level data stream processing capability!

My colleague asked a question I never thought about. Why did kubernetes' superfluous' launch the static pod concept?

How MySQL implements the RC transaction isolation level
随机推荐
Basic use of swiperefreshlayout, local refresh of flutterprovider
Yyds dry inventory executor package (executor function)
Orderly arrangement
How MySQL implements the RC transaction isolation level
buuresevewp
[NLP] vector retrieval model landing: Bottleneck and solution!
Class class of box selection four to and polygon box selection based on leaflet encapsulation
Mxnet implementation of network in Nin network
Detailed explanation of the generate go file command of import in golang (absolute detail)
[recommend 10 easy idea plug-ins with less tedious and repetitive code]
2021 project improvement
QT之一个UI里边多界面切换
Hand drawn style chart library chart Implementation principle of xkcd
[SystemVerilog basics] post_ Randomize function record
我想造SQL数据(存储结构)
职场“大冤种”,不仅身累,心也被掏空……
指南针炒股软件开户是合法的吗?安全吗
信息学奥赛一本通 1354:括弧匹配检验
Jemter 压力测试 -可视化工具-【使用篇】
Open a file at line with'filename:line'syntax - open a file at line with'filename:line' syntax