<!--WXML-->
<view id="box">
<view class="list" wx:for="{{List}}" wx:key="List{{index}}">
<image mode='aspectFill' class='list_img' src="{{item.imgUrl}}" ></image>
</view>
</view>
/* JS */
// 封装函数获取ID为box的元素实际高度
getScrollHeight: function() {
wx.createSelectorQuery().select('#box').boundingClientRect((rect) => {
this.setData({
scrollHeight: rect.height
})
console.log(this.data.scrollHeight)
}).exec()
},
// 假设数据请求
getDataList: function() {
wx.request({
url: 'test.php', //仅为示例,并非真实的接口地址
success: function(res) {
// 如果该元素下面的数据是动态获取的,此方法在wx.request请求成功的回调函数中调用
this.getScrollHeight()
}
})
},
|