动态计算控件frame 在页面加载完毕时计算 onLoad: function (options) { // 动态计算距离顶部高度 var that = this; var query = wx.createSelectorQuery() query.select('#affix').boundingClientRect() query.exec(function (res) { that.setData({ menuTop: res[0].top }) }) }