Home  >  Article  >  WeChat Applet  >  How to make scrolling pictures in a small program

How to make scrolling pictures in a small program

尚
Original
2020-03-21 14:05:364439browse

How to make scrolling pictures in a small program

Swipe left or right to switch display images:

<!--pages/test/test.wxml-->
<!-- 组件 -->
<swiper>
  <swiper-item wx:for="{{imgUrls}}">
    <image src=&#39;{{item}}&#39; width="335" height="150" mode=&#39;widthFix&#39; class=&#39;img&#39; />
  </swiper-item>
</swiper>

pages/test/test.js:

// pages/test/test.js
Page({
  data: {
    imgUrls:[
      &#39;http://dl.bizhi.sogou.com/images/1440x900/2014/05/14/611368.jpg&#39;,
      &#39;http://dl.bizhi.sogou.com/images/1440x900/2013/10/19/394877.jpg&#39;,                &#39;http://img04.sogoucdn.com/app/a/100520093/ca86e620b9e623ff-d72d635343d5bade-dcf2acda7a45cb44f172db138bdf8d2d.jpg&#39;,
    ]
  },
  //事件处理函数
  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!

Statement:
The content of this article is voluntarily contributed by netizens, and the copyright belongs to the original author. This site does not assume corresponding legal responsibility. If you find any content suspected of plagiarism or infringement, please contact admin@php.cn