KSwiper

滑块视图容器。其中只可放置一级 swiper-item 组件,否则会导致未定义的行为。

使用指南

  1. import {KSwiper} from 'kbone-ui'

实例

  1. <KSwiper
  2. :indicator-dots="indicatorDots"
  3. :circular="circularFlag"
  4. :autoplay="autoplay"
  5. :duration="duration"
  6. :interval="interval"
  7. >
  8. <KSwiperItem
  9. v-for="(item,index) in background"
  10. :key="index" >
  11. <KView :class="'swiper-item '+ item"/>
  12. </KSwiperItem>
  13. </KSwiper>

Swiper

Swiper 内容

KSwiper - 图1

使用参数

H5小程序属性类型默认值必填说明
oocurrent/v-modelnumber0当前所在滑块的 index, 推荐直接使用 v-model 监听值的改变
ooautoplaybooleanfalse是否自动切换
oointervalnumber5000自动切换时间间隔
oodurationnumber500滑动动画时长
oocircularbooleanfalse是否采用衔接滑动
overticalbooleanfalse滑动方向是否为纵向
ooindicator-dotsbooleanfalse是否显示面板指示点
oindicator-colorcolorrgba(0, 0, 0, .3)指示点颜色
oindicator-active-colorcolor#000000当前选中的指示点颜色
oprevious-marginstring"0px"前边距,可用于露出前一项的一小部分,接受 px 和 rpx 值
onext-marginstring"0px"后边距,可用于露出后一项的一小部分,接受 px 和 rpx 值
odisplay-multiple-itemsnumber1同时显示的滑块数量
oskip-hidden-item-layoutbooleanfalse是否跳过未显示的滑块布局,设为 true 可优化复杂情况下的滑动性能,但会丢失隐藏状态滑块的布局信息
oeasing-functionstring"default"指定 swiper 切换缓动动画类型
oobindchangeeventhandlecurrent 改变时会触发 change 事件,event.detail = {current, source}
obindtransitioneventhandleswiper-item 的位置发生改变时会触发 transition 事件,event.detail = {dx: dx, dy: dy}
obindanimationfinisheventhandle动画结束时会触发 animationfinish 事件,event.detail 同上

easing-function 的合法值

说明最低版本
default默认缓动函数
linear线性动画
easeInCubic缓入动画
easeOutCubic缓出动画
easeInOutCubic缓入缓出动画