当前位置:网站首页>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);
}
边栏推荐
猜你喜欢
随机推荐
Core Data浅谈系列之五 : 在UITableView中展示
金山云地震,震源在字节?
Domestic mobile phone manufacturers once fought for it, but now it is the first to collapse...
R语言ggplot2可视化:使用ggpubr包的ggerrorplot函数可视化误差线(可视化不同水平均值点以及se标准误差)、设置add参数为dotplot添加点阵图
OFDM 十六讲 7 - Inter-Symbol-Interference
力扣 1413. 逐步求和得到正数的最小值
leetcode:286.墙和门
(转)字符集编码标识符,数字表示字符编码
Js fifteen interview questions (with answers)
Cesium渐变色3dtiles白模(视频)
In-depth analysis of Apache EventMesh cloud-native distributed event-driven architecture
Presto Event Listener开发
发送激活邮件「建议收藏」
Postgresql源码(68)virtualxid锁的原理和应用场景
18-GuliMall 压力测试与性能监控
String hashing (2014 SERC J question)
FileZilla搭建FTP服务器图解教程
一文让你快速了解隐式类型转换【整型提升】!
typedef和#define的花里胡哨的用法
每日一R「02」所有权与 Move 语义