Weex 之图片自适应高度

2019-10-06 00:44:04 阅读:2 编辑

http://blog.sina.cn/dpool/blog/s/blog_133384b110102y7hq.html https://github.com/ZJWeex/imgload05

        <image src="https://s.zhyxm.com/img/icon/logo.png"  @load="onImageLoad"></image>
 showImage:function(event,width){
            var animation = weex.requireModule("animation");
            var img = event.target;
            var origin_width = event.size.naturalWidth;
            var origin_height = event.size.naturalHeight;
            var height = parseInt(width * origin_height /origin_width);
            animation.transition(img,{
                styles:{
                    width: width+'px',
                    height: height+'px'
                },
                duration: 0,
                timingFunction: 'ease',
                delay: 0,
                needLayout:true,
            }, function(){})
        },
        onImageLoad: function(event) {
            this.showImage(event,67 * 3);

        },