效果:
<view style="height: 180rpx;"></view>
<scroll-view :style="{height: scroll_height}" class="listBox" scroll-y="true"></scroll-view>
data() {
return {
scroll_height: 0
}
}
// 必须放在onReady里
onReady: function(res) {
var _this = this;
uni.getSystemInfo({
success: (resu) => {
const query = uni.createSelectorQuery()
query.select('.listBox').boundingClientRect()
query.exec(function(res) {
_this.scroll_height = resu.windowHeight - res[0].top + 'px';
})
},
fail: (res) => {}
})
},