scroll-view bindscroll

发布于 7 年前作者 gaolei5328 次浏览最后编辑 7 年前来自 ask

scroll-view  中使用 bindscroll,

就是滚动时候获取 scrollTop 的值,

多个判断 , 对应去改变导航菜单 显示的样式,会有卡顿,

如:

if (scrollTop < 515) {

      // console.log(11111111111)

      that.setData({

        monthactiveKey: 1

      })

      return;

    }

    if (scrollTop > 515 && scrollTop < 1030) {

      // console.log(222222222)

      that.setData({

        monthactiveKey: 2

      })

      return;

    }

页滚动的上面设置值范围的时候,对用导航显示的样式需要10s左右才会响应,很卡

9 回复
guiyingqiu
guiyingqiu1 楼6 年前

你的不用scroll-view不行吗?或者还是这个onPageScroll监听不到scroll-view的滚动高度。我没试过

lihou
lihou2 楼6 年前

亲你这个是scroll-view里面吗

min28
min283 楼6 年前

安卓机很卡

ios 快

xiuyingjin
xiuyingjin4 楼6 年前

我也是这样的问题~

dongna
dongna5 楼6 年前

在真机上都快。就是开发者工具上卡得要死。要过五六秒才会有效果

tanjun
tanjun6 楼6 年前

先下班走了。

leifang
leifang7 楼6 年前

我是这样写的

//监听页面滚动高度

  onPageScroll(res) {

    if (res.scrollTop >= 400) {

      this.setData({

        flag: true

      })

    } else {

      this.setData({

        flag: false

      })

    }

  },

chaoliang
chaoliang8 楼6 年前

if (scrollTop < 515 && that.data.monthactiveKey==2) {

      // console.log(11111111111)

      that.setData({

        monthactiveKey: 1

      })

      return;

    }

    if (scrollTop > 515 && scrollTop < 1030 && that.data.monthactiveKey==1) {

      // console.log(222222222)

      that.setData({

        monthactiveKey: 2

      })

      return;

    }

这么写会不会好点

xia21
xia219 楼5 年前

是在开发者工具上?真机上很快吧