鸿蒙5.0开发进阶:ArkUI框架-JS容器组件(swiper)

往期鸿蒙5.0全套实战文章必看:(文中附带全栈鸿蒙5.0学习资料)


swiper

滑动容器,提供切换子组件显示的能力。

说明

从API Version 8 开始支持。后续版本如有新增内容,则采用上角标单独标记该内容的起始版本。

属性

除支持通用属性外,还支持如下属性:

名称类型默认值必填描述
indexnumber0当前在容器中显示的子组件的索引值。
indicatorbooleantrue是否启用导航点指示器,默认true。
digitalbooleanfalse

是否启用数字导航点,默认为false。

必须设置indicator时才能生效数字导航点。

loopbooleantrue是否开启循环滑动。
durationnumber-子组件切换的动画时长。
verticalbooleanfalse是否为纵向滑动,纵向滑动时采用纵向的指示器。

样式

除支持通用样式外,还支持如下样式:

名称类型默认值必填描述
indicator-color<color>-导航点指示器的填充颜色。
indicator-selected-color<color>-导航点指示器选中的颜色。
indicator-size<length>4px导航点指示器的直径大小。
indicator-top|left|right|bottom<length> | <percentage>-导航点指示器在swiper中的相对位置。

事件

支持通用事件

示例

<!-- xxx.hml -->
<swiper class="container" index="{{index}}">
  <div class="swiper-item primary-item">
    <text>1</text>
  </div>
  <div class="swiper-item warning-item">
    <text>2</text>
  </div>
  <div class="swiper-item success-item">
    <text>3</text>
  </div>
</swiper>
/* xxx.css */
.container {
  left: 0px;
  top: 0px;
  width: 454px;
  height: 454px;
}
.swiper-item {
  width: 454px;
  height: 454px;
  justify-content: center;
  align-items: center;
}
.primary-item {
  background-color: #007dff;
}
.warning-item {
  background-color: #ff7500;
}
.success-item {
  background-color: #41ba41;
}
{
  "data": {
    "index": 1
  }
}

4*4卡片

评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值