ICode9

精准搜索请尝试: 精确搜索
首页 > 编程语言> 文章详细

小程序常用的几种轮播图

2020-04-27 16:55:53  阅读:228  来源: 互联网

标签:常用 轮播 image warp 几种 width height banner


轮播效果一      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;}

wxjs:

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;}

wxjs:

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%;}

 

 

标签:常用,轮播,image,warp,几种,width,height,banner
来源: https://www.cnblogs.com/liweitao/p/12787793.html

本站声明: 1. iCode9 技术分享网(下文简称本站)提供的所有内容,仅供技术学习、探讨和分享;
2. 关于本站的所有留言、评论、转载及引用,纯属内容发起人的个人观点,与本站观点和立场无关;
3. 关于本站的所有言论和文字,纯属内容发起人的个人观点,与本站观点和立场无关;
4. 本站文章均是网友提供,不完全保证技术分享内容的完整性、准确性、时效性、风险性和版权归属;如您发现该文章侵犯了您的权益,可联系我们第一时间进行删除;
5. 本站为非盈利性的个人网站,所有内容不会用来进行牟利,也不会利用任何形式的广告来间接获益,纯粹是为了广大技术爱好者提供技术内容和技术思想的分享性交流网站。

专注分享技术,共同学习,共同进步。侵权联系[81616952@qq.com]

Copyright (C)ICode9.com, All Rights Reserved.

ICode9版权所有