我必须在每个滚动上增加计数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++;
};