
1、要用定时,要在渲染之后一点点时间才有宽度
<view class="data_height" style="height:100px"><view style="height:{{target_height}}">
Page({data: {target_height: 0,},change_css() {setTimeout(() => {let query = wx.createSelectorQuery();query.select('.data_height').boundingClientRect(function(rect){let height = rect.height;console.log("height")console.log(height)that.setData({target_height: height+"px",})}).exec();},300)}