Micro letter applet scroll to the bottom or top wx.pageScrollTo and wx.createSelectorQuery

scrollBottom() {
      wx.createSelectorQuery()
        .select("#charRoom")
        .boundingClientRect(function(rect) {
          wx.pageScrollTo({
            scrollTop: rect.bottom,
            duration:0
          });
        })
        .exec();
}
复制代码

If the page is static, then, on the onReadylife cycle, so the page scrolls in the end portion of the rear ready. If the dynamic data should be performed on the request returns

  • wx.createSelectorQuery the api acquired page - the size of the face, and then wx.pageScrollToscroll to the corresponding position

    • .select('#id') Select the rolling element id

    • .boundingClientRect add queries layout position of the nodes. Returns the size and the position coordinates of four corners

  • wx.pageScrollTo applet api, scroll position.

Reproduced in: https: //juejin.im/post/5cff56476fb9a07ea33c0c23

Guess you like

Origin blog.csdn.net/weixin_33735676/article/details/93178951