这篇文章主要介绍了微信小程序 图片宽度自适应的实现的相关资料,需要的朋友可以参考下
微信小程序 图片宽度自适应的实现
实例代码:
wxml 代码:
1 2 3 4 5 6 7 | < swiper indicator-dots = "{{indicatorDots}}" autoplay = "{{autoplay}}" interval = "{{interval}}" duration = "{{duration}}" >
< block wx:for = "{{imgUrls}}" wx:key = "image" >
< swiper-item >
< image src = "{{item.image}}" model = "aspectFit" style = "width: {{imageWidth}}px;" bindload = "imageLoad" />
</ swiper-item >
</ block >
</ swiper >
|
js 代码:
1 2 3 4 5 6 7 8 9 10 11 12 13 14 | imageLoad: function () {
this .setData({
imageWidth: wx.getSystemInfoSync().windowWidth,
imgUrls: [
{ image: "http://img02.tooopen.com/images/20150928/tooopen_sy_143912755726.jpg" },
{ image: "http://img06.tooopen.com/images/20160818/tooopen_sy_175866434296.jpg" },
{ image: "http://img06.tooopen.com/images/20160818/tooopen_sy_175833047715.jpg" }],
indicatorDots: false ,
autoplay: true ,
interval: 2000,
duration: 1000
})
}
|
以上就是本文的全部内容,希望对大家的学习有所帮助。
版权声明:本文内容由网络用户投稿,版权归原作者所有,本站不拥有其著作权,亦不承担相应法律责任。如果您发现本站中有涉嫌抄袭或描述失实的内容,请联系我们jiasou666@gmail.com 处理,核实后本网站将在24小时内删除侵权内容。
暂时没有评论,来抢沙发吧~