我必须在每个滚动条上增加计数 1。例如:
let scrollCount = 0;
//initially it would be 0 and after every scroll up it should increase 1,
scrollCount++;
react-native中每次滚动时递增计数1的函数是什么。
//下面的js代码我知道..但是对于react-native来说会很困惑。
var scrollCount = 0;
window.addEventListener('mousewheel', function(e){
if(e.wheelDelta<=0 && scrollCount<5){
scrollCount++;
}
else if(e.wheelDelta>0 && scrollCount>1){
scrollCount--;
}
document.querySelector('.number').innerHTML = scrollCount;
});
最佳答案
object.onscroll = function(){
//myScript
};
每次滚动时运行脚本
或添加事件监听器:
object.addEventListener("scroll", myScript);
就变成这样了:
var scrollCount = 0;
//object is your document. or any DOM element you would like to add
object.onscroll = function(){
scrollCount++;
};
关于javascript - 如何增加向上滚动的计数,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/56076623/