当前位置:网站首页>抖音实战~首页视频~下拉刷新
抖音实战~首页视频~下拉刷新
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. 效果图

边栏推荐
- Decompilation of zero time technology smart contract security series articles
- vuex中利用缓存解决刷新state数据丢失问题
- How to create and enforce indexes
- DVD digital universal disc
- Feign remote call
- CD-CompactDisk
- 8VC Venture Cup 2017 - Final Round C. Nikita and stack
- Reading notes: process consulting III
- Soft test preparation multimedia system
- 一些基本错误
猜你喜欢
随机推荐
Union, intersection and difference operations in SQL
The successfully resolved idea cannot use the log normally after referencing Lombok's @slf4j
NFTGameFi链游系统开发详解方案丨链游系统开发原理解析
Redis Basics
【Mysql系列】工作常用sql集锦(持续更新)
问题解决:虚拟机无法复制粘贴文件
项目实战五:搭建ELk日志收集系统
物联网协议的王者:MQTT
8VC Venture Cup 2017 - Final Round C. Nikita and stack
Interview key points that must be mastered index and affairs (with B-tree and b+ tree)
Decompilation of zero time technology smart contract security series articles
[kubernetes] kubernetes principle analysis and practical application (under update)
Kubernetes resource topology aware scheduling optimization
Several delete operations in SQL
Summary of knowledge points
Clion compiling catkin_ WS (short for ROS workspace package) loads cmakelists Txt problems
xlua获取ugui的button注册click事件
Summary of alter operation in SQL
ROS的发布消息Publishers和订阅消息Subscribers
Publish message publishers and subscribe message subscribers of ROS









