# Swiper 轮播

# 使用指南

用于进行滑动切换场景,例如轮播图片或者tab内容。

# 代码演示

查看代码

# 与h3-mobile-vue组件的区别以及迁移

旧组件库轮播存在内置图片处理,为了让swiper组件更加纯粹,因此弃用内置图片处理及内置分页器。

若要做迁移请参考

  1. 弃用的props:list dotsPosition showDots showDescMask height aspectRatio mode

  2. 替换的props:

    • value => index
    • maxLength => maxlength
    • editable => readonly
  3. 新增的props:wait border password

  4. 弃用原来所有的事件

# API - H3Swiper

# Props - H3Swiper

参数 说明 类型 默认值
index 当前显示的 swipeItem 索引 或 item的 namev-model绑定值 string|number 0
direction 轮播方向 vertical horizontal string horizontal
auto 是否自动 boolean false
loop 是否循环播放 boolean false
interval 轮播间隔时间,单位 ms string|number 3000
threshold 滑动的临界值 string|number 0
duration 动画持续时间,单位 ms string|number 300
itemWidth 设置swiper-item宽度,当direction=horizontal时有效,若设置了,请把loop设置为false string|number -
itemHeight 设置swiper-item高度,当direction=vertical时有效,若设置了,请把loop设置为false string|number -
center 当设置了item-width item-height 时 是否居中显示 boolean true
touchable 是否可手动滑动 boolean true

# Events - H3Swiper

事件名 说明 参数
input swipeItem 索引变化时触发,v-model绑定事件 value: 当前索引
change swipeItem 索引变化时触发 options: {curr: 当前索引, prev: 前一个索引(若为-1则无前一个), next: 后一个索引(若为-1则无后一个), count: 总数}

# Function - H3Swiper

  • 实例方法
方法名 说明 参数
prev 滑动到前一个 -
next 滑动到后一个 -
swipeTo 滑动到指定一个 index
refresh 刷新组件 -

# API - H3SwiperItem

# Props - H3SwiperItem

参数 说明 类型 默认值
name item名称,作为匹配的标识符 string -