1 2 3 4 5 6 7 8 9
| pageScrollToBottom: function() { wx.createSelectorQuery().select('#j_page').boundingClientRect(function(rect){ wx.pageScrollTo({ scrollTop: rect.bottom }) }).exec() }
|
1 2 3 4 5 6 7 8 9 10 11
| <view class="wc-mes"> <scroll-view style="height: {{height}}px" scroll-x="false" scroll-y="true" scroll-top="{{scrollTop}}" > <view class="scroll-content">...</view> </scroll-view> </view> <view class="wc-bar">...</view>
|
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26
| calHeight() { let that = this; wx.createSelectorQuery().select('.wc-bar').boundingClientRect(function (rect) { that.setData({ height: wx.getSystemInfoSync().windowHeight - rect.height }) }).exec(); }
calScrollTop() { let that = this; wx.createSelectorQuery().select('.scroll-content').boundingClientRect(function (rect) { console.log(rect.height, that.data.height) if (rect.height > that.data.height) { that.setData({ scrollTop: rect.height }) } else { that.setData({ scrollTop: 0 }) } }).exec(); }
|