【微信小程序】常用的几种轮播图

轮播效果一

在这里插入图片描述
wxml:

<view class='pageBox pageOne'>
  <view class='list'>
    <swiper indicator-dots="{
    {true}}" autoplay="{
    {false}}" previous-margin="{
    {
    '140rpx'}}" next-margin="{
    {
    '140rpx'}}" bindchange="swiperChange">
      <block wx:for="{
    {imgUrls}}" wx:key="{
    {index}}">
        <swiper-item>
          <image src="{
    {item}}" class="slide-image {
    {swiperIndex == index ? 'active' : ''}}"/>
        </swiper-item>
      </block>
    </swiper>
  </view>
</view>

wxss:

.pageOne swiper{
   width: 750rpx;height: 900rpx;}
.pageOne swiper-item{
   padding-top: 100rpx;}
.pageOne image{
   width: 375rpx;height: 667rpx;position: absolute;left: 50%; margin-left: -188rpx;}
 .pageOne image.active{
   transform: scale(1.14);transition:all .2s ease-in 0s;}

js:

Page({
   
  data: {
   
    imgUrls: [
      'https://hbimg.huabanimg.com/9abd8e7d768e6bb070de86c09671b73c81de118d43df2-xahAjO_fw658',
      'https://hbimg.huabanimg.com/9abd8e7d768e6bb070de86c09671b73c81de118d43df2-xahAjO_fw658',
      'https://hbimg.huabanimg.com/9abd8e7d768e6bb070de86c09671b73c81de118d43df2-xahAjO_fw658'
    ],
   
    swiperIndex: 0
  },
  // 轮播特效果一
  swiperChange(e) {
   
    this.setData({
   
      swiperIndex: e.detail.current
    })
  },
})

轮播效果二

在这里插入图片描述
wxml:

<view class='pageBox pageTwo'>
  <swiper class='swiperClass' autoplay indicator-color="#a39f99" indicator-active-color="#f49641" indicator-dots  interval="2000" duration="1000" previous-margin="60px" next-margin="60px" circular bindchange="bindchange" style='height: { { swiperHeight}}px'>
  <block wx:for="{
    {imgUrls}}" wx:key="{
    {index}}">
    <swiper-item>
      <image src="{
    {item}}" class="slide-image {
    {swiperIdx == index ? 'active' : 'quiet'}}" mode='aspectFill'></image>
    </swiper-item>
  </block>
 </swiper>
</view>

wxss:

.pageTwo .swiperClass {
   margin: 0;margin-top: 10px;}
.pageTwo .slide-image {
   width: 100%;height: 90%;border-radius: 10px;position: relative;box-shadow: 0 0 10rpx rgba(0, 0, 0, .8)}
.pageTwo image.active {
   transform: none;transition: all 0.2s ease-in 0s;} 
.pageTwo image.quiet {
   transform: scale(0.8333333);transition: all 0.2s ease-in 0s;}

js:

Page({
   
  data: {
   
    imgUrls: [
      'https://hbimg.huabanimg.com/9abd8e7d768e6bb070de86c09671b73c81de118d43df2-xahAjO_fw658',
      'https://hbimg.huabanimg.com/9abd8e7d768e6bb070de86c09671b73c81de118d43df2-xahAjO_fw658',
      'https://hbimg.huabanimg.com/9abd8e7d768e6bb070de86c09671b73c81de118d43df2-xahAjO_fw658'
    ],
    
    swiperIdx: 0
  },
  /,
  // 轮播特效果二
  bindchange(e) {
   
    this.setData({
   
      swiperIdx: e.detail.current
    })
  },

})

轮播效果三

在这里插入图片描述

wxml:

<view class='banner_warp'>
  <swiper class='banner' autoplay='true' circular='true' indicator-dots='true'>
    <block wx:for='{
    {3}}' wx:key='' wx:key='{
    {index}}'>
      <swiper-item>
        <view class='li '>
          <image src='https://hbimg.huabanimg.com/9abd8e7d768e6bb070de86c09671b73c81de118d43df2-xahAjO_fw658' mode='aspectFill'></image>
        </view>
      </swiper-item>
    </block>
  </swiper>
</view>

wxss:

.banner_warp,.banner_warp .banner,.banner_warp image{
   height:264rpx;}
.banner_warp{
   margin-top: 30rpx;}
.banner_warp .banner_warp .li{
   border-radius: 20rpx;width: 92%;overflow: hidden}
.banner_warp .wx-swiper-dot{
   width: 40rpx;height: 6rpx;background: rgba(255,255,255,.2);border-radius: inherit;}    
.banner_warp .wx-swiper-dot-active{
   width: 40rpx;height: 6rpx;background: #fff;}
.banner_warp image{
   border-radius: 20rpx;}

轮播效果四

在这里插入图片描述
wxml:

<swiper class='swiper' autoplay='true' circular='true' style="margin-top:30rpx">
  <swiper-item  wx:for='{
    {imgArr}}'>
    <image data-index='{
    {index}}' bindtap='previewImg' src='https://hbimg.huabanimg.com/9abd8e7d768e6bb070de86c09671b73c81de118d43df2-xahAjO_fw658' mode="aspectFill"></image> </swiper-item> </swiper>

wxss:

.swiper{
   width: 100%;height: 500rpx;}
.swiper image{
   width: 100%;height: 100%;}

相关推荐

  1. 程序九宫格布局,

    2024-01-27 06:28:05       47 阅读
  2. 程序实现

    2024-01-27 06:28:05       22 阅读
  3. 程序

    2024-01-27 06:28:05       6 阅读
  4. 程序 且跳转公众号文章

    2024-01-27 06:28:05       34 阅读

最近更新

  1. TCP协议是安全的吗?

    2024-01-27 06:28:05       18 阅读
  2. 阿里云服务器执行yum,一直下载docker-ce-stable失败

    2024-01-27 06:28:05       19 阅读
  3. 【Python教程】压缩PDF文件大小

    2024-01-27 06:28:05       18 阅读
  4. 通过文章id递归查询所有评论(xml)

    2024-01-27 06:28:05       20 阅读

热门阅读

  1. Form.List的使用,设置某个字段的值

    2024-01-27 06:28:05       32 阅读
  2. overflow产生的滚动条样式设置

    2024-01-27 06:28:05       39 阅读
  3. 介绍一下OpenCV中常用的图像处理函数

    2024-01-27 06:28:05       26 阅读
  4. uniapp获取定位

    2024-01-27 06:28:05       28 阅读
  5. 看书标记【数据科学:R语言实战 2】

    2024-01-27 06:28:05       28 阅读
  6. Lowest Common Ancestor

    2024-01-27 06:28:05       36 阅读
  7. 汇编中$+6的意义与理解

    2024-01-27 06:28:05       34 阅读
  8. ES系列索引、文档、集群、技术原理文章目录

    2024-01-27 06:28:05       33 阅读
  9. 【算法题】74. 搜索二维矩阵

    2024-01-27 06:28:05       28 阅读
  10. 初识HarmonyOS

    2024-01-27 06:28:05       33 阅读