小程式圖片widhtFix屬性載入時圖片拉長
阿新 • • 發佈:2019-01-30
網上找的方法試了一下,還不錯效果:
先將圖片隱藏hidden,然後當圖片載入完成bindload後再將圖片漸漸顯示出來,高度設為auto,這樣效果還不錯
1.wxml
<image hidden="{{!showPic}}" animation="{{animationData}}" style="opacity:0;height:auto" bindload="showPicture" src='{{info.img}}' mode="widthFix"></image>
2.js
showPicture: function (){
let that = this
let show = that.data.showPic
let animation = wx.createAnimation({
duration: 500,
timingFunction: 'ease-in',
delay: 0
})
show = true
animation.opacity(1).step()
that.setData({
showPic: show,
animationData: animation.export()
})
},