1.0.0 • Published 5 years ago

rui-wx-swiper v1.0.0

Weekly downloads
1
License
ISC
Repository
-
Last release
5 years ago

GitHub 下载 WX-RUI 的代码,将 component 目录拷贝到自己的项目中。然后按照如下的方式使用组件,以 swiper 为例,其它组件在对应的文档页查看:

1. 添加需要的组件。在页面的 json 中配置(路径根据自己项目位置配置):

"usingComponents": {
  "rui-swiper": "../../component/swiper/swiper"
}

2. 在 wxml 中使用组件:

2.1 常规滑动轮播

<rui-swiper   
  swiperList="{{bannerList}}"   
  indicatorDots="true"   
  autoplay="true"
></rui-swiper>

2.2 衔接滑动轮播(循环滑动轮播)

<rui-swiper   
  swiperList="{{bannerList}}"   
  indicatorDots="true"   
  autoplay="true"   
  circular="true"
></rui-swiper>
效果图1 ---- 常规滑动轮播和循环滑动轮播

常规滑动轮播和循环滑动轮播

2.3 纵向滑动轮播

<rui-swiper   
  swiperList="{{bannerList}}"   
  indicatorDots="true"   
  autoplay="true"   
  vertical="true"
></rui-swiper>

2.4 纵向衔接滑动轮播(纵向循环滑动轮播)

<rui-swiper   
  swiperList="{{bannerList}}"   
  indicatorDots="true"   
  autoplay="true"   
  circular="true"   
  vertical="true"
></rui-swiper>
效果图2 ---- 纵向滑动轮播和纵向循环滑动轮播

纵向滑动轮播和纵向循环滑动轮播

2.5 后边距滑动

<rui-swiper   
  swiperList="{{bannerList}}"   
  indicatorDots="true"   
  autoplay="true"   
  imgwidth="90vw"   
  circular="true"   
  next-margin="30px"
></rui-swiper>

2.6 前后边距滑动轮播

<rui-swiper   
  swiperList="{{bannerList}}"   
  indicatorDots="true"   
  autoplay="true"   
  current='{{current}}'   
  isOpacity="true"   
  isScale="true"    
  imgwidth="82vw"   
  circular="true"   
  previous-margin="30px"   
  next-margin="30px"   
  rui-class="rui-banner-img"  
  bindswiperfinish='changeFun'
></rui-swiper>
效果图3 ---- 后边距滑动和前后边距滑动轮播

后边距滑动和前后边距滑动轮播

2.7 多图片滑动轮播

<rui-swiper   
  swiperList="{{bannerList}}"   
  circular="true"   
  autoplay="true"   
  display-multiple-items="2"   
  swiperheight="21.333vw"   
  imgheight="21.333vw"   
  imgwidth="50vw"   
  current='0'
></rui-swiper>

2.8 文字滑动导航

<rui-swiper   
  type="text"   
  class='rui-active'   
  swiperList="{{navList}}"   
  display-multiple-items="4"   
  swiperheight="12vw"   
  imgheight="12vw"   
  previous-margin="10px"   
  next-margin="10px"   
  current='{{current_text}}'   
  circular="true"   
  imgwidth="calc((100vw - 20px) / 4 - 40px)"   
  bindswipertap="getIndex"
></rui-swiper>
效果图4 ---- 多图片滑动轮播和文字滑动导航效果图

多图片滑动轮播和文字滑动导航效果图

参数说明

属性名类型默认值说明
swiperwidthString   ''swiper的宽度
swiperheightString    ''swiper的高度
imgwidthString    ''swiper中图片的宽度
imgheightString    ''swiper中图片的高度
swiperListArray    []swiper的内容数组
intervalNumber    5000自动切换时间间隔
durationNumber    500滑动动画时长
displayMultipleItemsNumber   1同时显示的滑块数量
currentNumber   0当前所在滑块的 index
currentItemIdString   ''当前所在滑块的 item-id ,不能与 current 被同时指定
indicatorColorString   ''指示点颜色
indicatorActiveColorString   ''当前选中的指示点颜色
previousMarginString   '0px'前边距,可用于露出前一项的一小部分,接受 px 和 rpx 值
nextMarginString   '0px'后边距,可用于露出后一项的一小部分,接受 px 和 rpx 值
autoplayBoolean   false是否自动切换
circularBoolean   false是否采用衔接滑动
verticalBoolean   false滑动方向是否为纵向
indicatorDotsBoolean   false是否显示面板指示点
isOpacityBoolean   false是否设置图片透明度
isScaleBoolean   false是否设置图片缩放比例
skipHiddenItemLayoutBoolean   false是否跳过未显示的滑块布局,设为 true 可优化复杂情况下的滑动性能,但会丢失隐藏状态滑块的布局信息

事件说明:

事件名称类型默认值说明
bindswiperchangeEventHandle   current 改变时会触发 change 事件,event.detail = {current: current}
bindswiperfinishEventHandle   动画结束时会触发 animationfinish 事件,event.detail 同上

WXRUI体验二维码

WXRUI体验码

如果文章对你有帮助的话,请打开微信扫一下二维码,点击一下广告,支持一下作者!谢谢!

其他

我的博客,欢迎交流!

我的CSDN博客,欢迎交流!

微信小程序专栏

前端笔记专栏

微信小程序实现部分高德地图功能的DEMO下载

微信小程序实现MUI的部分效果的DEMO下载

微信小程序实现MUI的GIT项目地址

微信小程序实例列表

前端笔记列表

游戏列表