滑块容器(aip-swiper & aip-swiper-item)

滑块视图容器,内部只允许使用<aip-swiper-item>组件来描述具体滑块内容,否则会导致未定义的行为。

示例

<aip-swiper>
    <aip-swiper-item>
        <aip-img src="/static/hello.png"></aip-img>
    </aip-swiper-item>
    <aip-swiper-item>
        <aip-img src="/static/hello.png"></aip-img>
    </aip-swiper-item>
</aip-swiper>
1
2
3
4
5
6
7
8

引入

<script
    defer
    src="https://unpkg.byted-static.com/latest/byted-fangyuan/aip-ui/dist/aip-swiper/aip-swiper.iife.js"
></script>
1
2
3
4

aip-swiper 支持的属性

属性说明
modenormal、carousel、coverflow、flat-coverflow,H5 不支持这个字段,只有 normal 效果
indicator-dots是否显示面板指示点
indicator-color指示点颜色
indicator-active-color指示点激活颜色
autoplay是否自动播放
interval自动切换时间间隔
duration滑动动画时长
circular是否首尾循环
touchable是否让用户可以滑动
current当前选中滑块的 index,初始生效

H5 只有 autoplay 和 duration 支持动态改变其值,然后实时响应变化,其他属性不支持。原生渲染安卓支持动态切换 autoplay, duration, circular 和 touchable;原生渲染 iOS 支持动态切换 circular 和 touchable。需要注意的是:autoplay 在 H5 是循环播放的意思,在原生页渲染中是自动播放下一个 item 的意思(如果没有设置 circular,那么到达最后一个 item 就会停下来)。

需要注意的是:目前 duration 在 iOS 的原生渲染上只能是默认的 500 ms,无法设置成其他值;一般情况下,interval(自动切换时间间隔)要大于 duration(滑动动画时间),以下两种情况尽量避免:1、touchable=true,autoplay=true,用户滑动导致剩余的自动切换时间间隔小于滑动动画时间,则可能出现未知问题;2、autoplay=true,interval 小于 duration,也可能出现未知问题,比如滑动卡顿。

mode 取值具体含义:

  • normal: 宽高均为 100%
  • carousel: 宽:80%,高:100%,仅支持原生渲染,不支持 H5
  • coverflow: 宽:60%,高:100%,仅支持原生渲染,不支持 H5
  • 立体翻转效果,flat-coverflow: 宽:60%,高:100%,水平翻动效果,仅支持原生渲染,不支持 H5
Last Updated: 2022/7/15 下午7:22:06