1.在需要滚动的view外层id
2.data里边声明函数
3.滚动方法函数
let that = this;
wx.createSelectorQuery().select('#communication').boundingClientRect(function (rect) {
wx.pageScrollTo({
scrollTop: rect.height,
duration: 100 // 滑动速度
})
that.setData({
scrollTop: rect.height - that.data.scrollTop
});
}).exec();