Detailed explanation of how to use the image carousel component gallery slider

小云云
Release: 2018-02-02 10:25:49
Original
2829 people have browsed it

This article mainly introduces in detail how to use the WeChat mini program image carousel component gallery slider. It has certain reference value. Interested friends can refer to it. I hope it can help everyone.

First the renderings:

Detailed explanation of how to use the image carousel component gallery slider

##wxml


<scroll-view scroll-y="true" style="height:200px" class="page-body" bindscrolltolower="loadMore">
 <view class="swiper">
  <swiper class="swiper-box" indicator-dots="{{indicatorDots}}" vertical="{{vertical}}"
      autoplay="{{autoplay}}" interval="{{interval}}" duration="{{duration}}"
      indicator-color="#fff" indicator-active-color="red">
    <block wx:for-items="{{banner_url}}" wx:key="item.id">
      <navigator url="../blogList/blogList">
       <swiper-item>
        <block wx:if="{{item}}">
         <image class="imgw" src="{{item.url}}" mode="aspectFill"/>
        </block>
        <block wx:else>
         <image src="../../images/default_pic.png" mode="aspectFill"></image>
        </block>
       </swiper-item>
      </navigator>
    </block>
  </swiper>
 </view>
</scroll-view>
Copy after login

wxss


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

js


/**
 *页面的初始数据
 */
data: {
 banner_url: data.bannerList(),
 open: false,
 indicatorDots: true,//是否显示面板指示点
 autoplay: true,//是否开启自动切换
 interval: 3000,//自动切换时间间隔
 duration: 500//滑动动画时长
}
Copy after login

Final effect:

Detailed explanation of how to use the image carousel component gallery slider

##Summary:


1. The scroll-view component is used to trigger touch sliding

2. The swiper component is used to automatically switch images to form a carousel

3. The navigator component The function is to add a link to each image
Mainly the two components scroll-view and swiper are made into a sliding carousel component.

Related recommendations:

Detailed encapsulation of React Native vertical carousel component

React Native notification message vertical carousel component Detailed explanation of encapsulation

JavaScript implementation of image carousel component code example

The above is the detailed content of Detailed explanation of how to use the image carousel component gallery slider. 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