当前位置:网站首页>抖音实战~首页视频~下拉刷新
抖音实战~首页视频~下拉刷新
2022-06-26 18:49:00 【gblfy】
1. 配置下拉刷新
在pages.json
配置文件中添加如下配置:
"enablePullDownRefresh":true //开启下拉刷新
2. 下拉刷新监听
// 当前页下拉刷新
onPullDownRefresh() {
var me = this;
// 监听tab
console.log("me.curIndex",me.curIndex)
// 下拉刷新判断,如果是不同tab,那么组件中刷新的请求也不同
if (me.curIndex == 0) {
// 虚位以待
} else if (me.curIndex == 1) {
// 调用公共视频组件查询首页短视频列表
this.$refs.videoFollowComp.displayVideoPaging(1, true);
} else if (me.curIndex == 2) {
// 调用公共视频组件查询首页短视频列表
this.$refs.videoComp.displayVideoPaging(1, true);
}
}
3. tab监听索引
tab页面 | 监听当前索引方法 | 获取监听api | 索引 |
---|---|---|---|
附近 | onPullDownRefresh | me.curInde | 0 |
关注 | onPullDownRefresh | me.curInde | 1 |
推荐 | onPullDownRefresh | me.curInde | 2 |
4. 控制台监控
5. 父子组件调用
- 父页面index.nvue
this.$refs.videoFollowComp.displayVideoPaging(1, true);
- 子组件videoComp.vue
// 分页查询新的list,并且追加到现有list中
displayVideoPaging(page, needClearList) {
// 查询首页短视频列表
var me = this;
var myUserInfo = getApp().getUserInfoSession();
// console.log("首页",myUserInfo)
var userId = "";
if (myUserInfo != null) {
userId = myUserInfo.id;
}
var serverUrl = app.globalData.serverUrl;
uni.request({
method: "GET",
header: {
headerUserId: userId,
headerUserToken: app.getUserSessionToken()
},
url: serverUrl + "/vlog/indexList?userId=" + userId + "&page=" + page + "&pageSize=10",
success(result) {
if (result.data.status == 200) {
var vlogList = result.data.data.rows;
var totalPage = result.data.data.total;
// me.playerList = vlogList;
if (needClearList) {
me.playerList = [];
}
me.playerList = me.playerList.concat(vlogList);
me.page = page;
me.totalPage = totalPage;
if (needClearList) {
me.setThisVlogInfo();
me.freshCommentCounts();
}
} else {
uni.showToast({
title: result.data.msg,
icon: "none",
duration: 3000
});
}
},
complete() {
uni.stopPullDownRefresh();
}
});
}
6. 效果图
边栏推荐
- Xlua get button registration click event of ugui
- Yujun product methodology
- Decompilation of zero time technology smart contract security series articles
- Nftgamefi chain game system development detailed solution - chain game system development principle analysis
- 【Mysql系列】工作常用sql集锦(持续更新)
- DAPP丨LP单双币流动性质押挖矿系统开发原理分析及源码
- 问题解决:虚拟机无法复制粘贴文件
- Interview key points that must be mastered index and affairs (with B-tree and b+ tree)
- 物联网协议的王者:MQTT
- ROS的发布消息Publishers和订阅消息Subscribers
猜你喜欢
Take you to resolve hash conflicts and implement a simple hash table,
Pinda general permission system (day 3~day 4)
Microservice architecture
Boot的单元测试
Installation and use of logstash
Web resource preloading - production environment practice
Solidity - contract inheritance sub contract contains constructor errors and one contract calls the view function of another contract to charge gas fees
(树) 树状数组
Clion compiling catkin_ WS (short for ROS workspace package) loads cmakelists Txt problems
自己创建一个时间拦截器
随机推荐
CLion断点单步调试
IK word breaker
[kubernetes] kubernetes principle analysis and practical application (under update)
刷新三观的HP-UX系统中的强指针赋值出core问题
Web resource preloading - production environment practice
Conditional compilation in precompiling instructions
CD-CompactDisk
sql 中的alter操作总结
8VC Venture Cup 2017 - Final Round C. Nikita and stack
Preliminary analysis of serial port printing and stack for arm bare board debugging
Boot指标监测
Pinda general permission system (day 3~day 4)
限流设计及实现
Do you know how to compare two objects
Xlua get button registration click event of ugui
NFTGameFi链游系统开发详解方案丨链游系统开发原理解析
Clion breakpoint single step debugging
stm32和电机开发(直流有刷电机和步进电机)
Refresh the strong pointer assignment problem in the HP-UX system of Sanguan
MySQL recharge