Swipe left or right to switch display images:
<!--pages/test/test.wxml--> <!-- 组件 --> <swiper> <swiper-item wx:for="{{imgUrls}}"> <image src='{{item}}' width="335" height="150" mode='widthFix' class='img' /> </swiper-item> </swiper>
pages/test/test.js:
// pages/test/test.js Page({ data: { imgUrls:[ 'http://dl.bizhi.sogou.com/images/1440x900/2014/05/14/611368.jpg', 'http://dl.bizhi.sogou.com/images/1440x900/2013/10/19/394877.jpg', 'http://img04.sogoucdn.com/app/a/100520093/ca86e620b9e623ff-d72d635343d5bade-dcf2acda7a45cb44f172db138bdf8d2d.jpg', ] }, //事件处理函数 toupper:function(){ console.log("触发了toupper"); } })
pages/test/test.wxss:
.img{ width: 100%; }
Experience:
swiper component: slider view container.
You can add the autoplay attribute to swiper to automatically play it, for example: autoplay="true"
The image single label is used in the swiper component, not the double label (otherwise an error will be reported).
Recommendation: " Mini Program Development Tutorial"
The above is the detailed content of How to make scrolling pictures in a small program. For more information, please follow other related articles on the PHP Chinese website!