当前位置:网站首页>UNI-APP_监听页面滚动h5监听页面滚动
UNI-APP_监听页面滚动h5监听页面滚动
2022-08-09 22:03:00 【小歪 | 前端】
1.在uniapp中,使用生命周期onPageScroll()
onPageScroll(e) {
console.log(e.scrollTop)
if (e.scrollTop >= 120) {
console.log(true)
} else {
}
},
2.在普通h5页面中使用原生js进行监听
window.onscroll = function () {
//为了保证兼容性,这里取三个值,哪个有值取哪一个
//scrollTop就是触发滚轮事件时滚轮的高度
var scrollTop = window.pageYOffset || document.documentElement.scrollTop || document.body.scrollTop;
console.log("滚动距离" + scrollTop);
}
边栏推荐
- CGLIB源码易懂解析
- This article lets you quickly understand implicit type conversion [integral promotion]!
- leetcode brush questions diary Calculate the number of elements on the right that is less than the current element
- Chatting embarrassing scenes, have you encountered it?Teach you to get the Doutu emoticon package with one click, and become a chat expert
- 级联下拉菜单的实现「建议收藏」
- 面试官:Redis 大 key 要如何处理?
- (转)FreeType字体位图属性
- README_Albumentations
- 【技术分享】SLA(服务等级协议)原理与配置
- R语言检验时间序列的平稳性:使用tseries包的adf.test函数实现增强的Dickey-Fuller(ADF)检验、检验时序数据是否具有均值回归特性(平稳性)、不具有均值回归特性的案例
猜你喜欢
随机推荐
孙正义亏掉1500亿:当初投贵了
Easyui 表单验证「建议收藏」
国内手机厂商曾为它大打出手,如今它却最先垮台……
阿里云架构师金云龙:基于云XR平台的视觉计算应用部署
第 1 章 一大波数正在靠近——排序
月薪5K的运维小白如何成为月薪5W的高级架构师?
leetcode brush questions diary Calculate the number of elements on the right that is less than the current element
How do task flow executors work?
A1. Prefix Flip (Easy Version)
R语言拟合ARIMA模型并使用拟合模型进行预测推理:使用forecast函数计算ARIMA模型未来值(包含时间点、预测值、两个置信区间)
NodeJS使用JWT
One Pass 2074: [21CSPJ Popularization Group] Candy
R语言ggstatsplot包grouped_ggscatterstats函数可视化分组散点图、并添加假设检验结果(包含样本数、统计量、效应大小及其置信区间、显著性、组间两两比较、贝叶斯假设)
为什么这么多人都想当产品经理?
好未来,想成为第二个新东方
JS–比想象中简单
深度剖析 Apache EventMesh 云原生分布式事件驱动架构
Flutter 绘制美不胜收的光影流动效果
c:forEach varStatus属性
js array object deduplication









