Home > WeChat Applet > Mini Program Development > How to make scrolling pictures in a small program

How to make scrolling pictures in a small program

Release: 2020-03-21 14:05:36
Original
4539 people have browsed it

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>
Copy after login

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");
  }
})
Copy after login

pages/test/test.wxss:

.img{
 width: 100%;
}
Copy after login

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!

Related labels:
source:php.cn
Statement of this Website
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
Popular Tutorials
More>
Latest Downloads
More>
Web Effects
Website Source Code
Website Materials
Front End Template