小程序-自适应图片 最多3张

139 阅读1分钟
    for (var i in rol) {
      // rol[i].pic = JSON.parse(rol[i].pic)
      var list = rol[i].allimg;
      rol[i].picurl = [];
      rol[i].picwidth = '';
      rol[i].picheight = '';
      if (list.length == 1) {
        rol[i].picwidth = 'width:' + (wx.getSystemInfoSync().windowWidth - 40) + 'px;';
        rol[i].picheight = 'height:' + (wx.getSystemInfoSync().windowWidth - 40) + 'px;';
      } else if (list.length == 2) {
        rol[i].picwidth = 'width:' + (wx.getSystemInfoSync().windowWidth - 50) / 2 + 'px;';
        rol[i].picheight = 'height:' + (wx.getSystemInfoSync().windowWidth - 50) / 2 + 'px;';
      } else {
        rol[i].picwidth = 'width:' + (wx.getSystemInfoSync().windowWidth - 55) / 3 + 'px;';
        rol[i].picheight = 'height:' + (wx.getSystemInfoSync().windowWidth - 55) / 3 + 'px;';
      }       
    }
    var list = [];
   
    list = that.data.class_data;
      that.setData({
        class_data: list.concat(rol)
      })