微信小程序 scroll-view 根据内容的高度自适应

 有问题可以扫码加我微信,有偿解决问题。承接小程序开发。

微信小程序开发交流qq群   173683895  、 526474645 ;

正文:

1


<video autoplay src="{{videoPlayUrl}}" controls></video>
<scroll-view scroll-y style="height: {{height?height+'px':'auto'}}">
  <view class='wwww' id='www'>
    <view>111</view>
    <view>111</view>
    <view>111</view>
    <view>111</view>
    <view>111</view>
    <view>111</view>
  </view>
</scroll-view>

2

.wwww view{
  height: 200rpx;
  background: wheat
}

3

var is_1_height;
Page({

  //生命周期函数--监听页面加载
  onLoad: function(options) {
    var that=this;
    wx.getSystemInfo({
      success: function (res) {
        wx.createSelectorQuery().select('video').boundingClientRect(function (rect) {
          var is_1_height = Number(rect.height) // 节点的宽度
          that.setData({
            height: Number(res.windowHeight) - is_1_height
          });
        }).exec();
      }
    });
  }
})

猜你喜欢

转载自blog.csdn.net/qq_35713752/article/details/81665551