scroll-view bindscroll
发布于 5 年前 作者 gaolei 5094 次浏览 来自 问答

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 回复

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

亲你这个是scroll-view里面吗

安卓机很卡

ios 快

我也是这样的问题~

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

先下班走了。

我是这样写的

//监听页面滚动高度

  onPageScroll(res) {

    if (res.scrollTop >= 400) {

      this.setData({

        flag: true

      })

    } else {

      this.setData({

        flag: false

      })

    }

  },

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;

    }

这么写会不会好点

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

回到顶部