• 在应用中显示的图片很多情况不满足业务需求,我们需要动态根据图片的宽高进行缩放或加载中显示的缺省图片,这是我没就需要监听图片加载完成回调,来看看微信小程序怎么实现图片加载完成回调。


                       <swiper-item>
                            <image src="{{item.image}}" class="slide-image" mode="widthFix" @tap="bannerjump({{item.link}})" data-url="{{item.link}}" bindload="imageLoad"  style="height:{{imgheights[swiperCurrent]}}rpx;{{imgwidth}}rpx;"/>
                        </swiper-item>
    
      // 获取banner图高度
                imageLoad: function (e) {  
                   var self = this;
                    //获取图片真实宽度  
                    var imgwidth = e.detail.width,  
                      imgheight = e.detail.height,  
                      //宽高比  
                      ratio = imgwidth / imgheight;  
                     
                    //计算的高度值  
                    var viewHeight = 750 / ratio;  
                    var imgheight = viewHeight  
                    var imgheights = this.data.imgheights  
                    //把每一张图片的高度记录到数组里  
                    imgheights.push(imgheight)  
                    
                    this.imgheights = imgheights
    
                    this.$apply();           
                },
    

    最近发懒筋 不想说话 一句话都不想说 别怪我 用吧 ~~~~~

  • 相关阅读:
    文件预览
    Intellij IDEA 配置热部署
    Spring AOP
    Spring配置Bean
    Zookeeper浅谈
    Select 可编辑下拉框
    String常见问题
    Character类--字符操作
    Android Environment FAQ (Frequently Asked Question)
    Unity Texture 2D Compress
  • 原文地址:https://www.cnblogs.com/antyhouse/p/9812122.html
Copyright © 2020-2023  润新知