小程序坑多,还是用uni-app来写小程序好点
附:
onReady: function () { const query = uni.createSelectorQuery().in(this); query.select('#d').boundingClientRect(data => { this.home_page_height=data.top*2; }).exec(); }