页面上有一个元素或者组件,id 为 comment
则:
var me = this; var query = wx.createSelectorQuery().in(me); query.selectViewport().scrollOffset() query.select("#comment").boundingClientRect(); query.exec(function (res) { console.log(res); var miss = res[0].scrollTop + res[1].top - 10; wx.pageScrollTo({ scrollTop: miss, duration: 300 }); });