The carousel function of WeChat applets

Source: Internet
Author: User
We can see the carousel descriptions on the official website. here we use an instance to illustrate the implementation effect of the carousel function of a small program: We can see the carousel descriptions on the official website, here is an example to illustrate the implementation of the carousel function of the applet:


Let's take a look at it first:

JS code:

var app = getApp();Page({    data: {        imgUrls: [            'http://img02.tooopen.com/images/20150928/tooopen_sy_143912755726.jpg',            'http://img06.tooopen.com/images/20160818/tooopen_sy_175866434296.jpg',            'http://img06.tooopen.com/images/20160818/tooopen_sy_175833047715.jpg'        ],        indicatorDots: true,        autoplay: false,        interval: 5000,        duration: 1000    },    changeIndicatorDots: function(e) {        this.setData({            indicatorDots: !this.data.indicatorDots        })    },    changeAutoplay: function(e) {        this.setData({            autoplay: !this.data.autoplay        })    },    intervalChange: function(e) {        this.setData({            interval: e.detail.value        })    },    durationChange: function(e) {        this.setData({            duration: e.detail.value        })    },})

Data is the data to be set. Whether the indicatorDots setting is a bit, the interval setting is to switch every several milliseconds, and the duration setting is to set the switching speed. Traverse all the photos. These values are set through data in the function.

WXML code:

     
          
               
            
       
  
 

The above is the carousel process, the main application component, autoplay sets whether to play automatically, interval sets the switching interval in milliseconds, and duration sets the switching speed. Traverse all the photos.

The carousel effect can be achieved through simple configuration, which is very easy to implement.

For more articles about the carousel function of small programs, please follow the PHP Chinese network!

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.