小程序容器根据比例适应图片

<view class="swiper" style="height:{{sHeight}}px">
  </view>

 



imgLoad:function(){ var that = this; wx.getSystemInfo({ success: function (res) { // 获取设备宽度 var infoWidth = res.screenWidth-20; console.log(infoWidth) // 设置比例 var bili = 640/350; // 得到高度 var $height = infoWidth/bili; console.log($height) that.setData({ sHeight: $height }) } }) },

 

posted @ 2018-03-06 14:55  zc_boy  阅读(916)  评论(0编辑  收藏  举报