harmony 鸿蒙swiper

2022-12-13 浏览 (789)

swiper

The <Swiper> component provides a container that allows users to switch among child components using swipe gestures.

NOTE

The APIs of this module are supported since API version 8. Updates will be marked with a superscript to indicate their earliest API version.

Attributes

In addition to the universal attributes, the following attributes are supported.

NameTypeDefault ValueMandatoryDescription
indexnumber0NoIndex of the child component currently displayed in the container.
indicatorbooleantrueNoWhether to enable the indicator. The default value is true.
digitalbooleanfalseNoWhether to enable the digital indicator. The default value is false.
The digital indicator takes effect only when indicator is set to true.
loopbooleantrueNoWhether to enable looping.
durationnumber-NoDuration of the autoplay for child component switching.
verticalbooleanfalseNoWhether the swipe gesture is performed vertically. A vertical swipe uses the vertical indicator.

Styles

In addition to the universal styles, the following styles are supported.

NameTypeDefault ValueMandatoryDescription
indicator-color<color>-NoFill color of the indicator.
indicator-selected-color<color>-NoColor of the currently selected indicator.
indicator-size<length>4pxNoDiameter of the indicator.
indicator-top|left|right|bottom<length> |<percentage>-NoRelative position of the indicator in the swiper.

Events

The universal events are supported.

Example

<!-- 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 x 4 widget

Swiper

你可能感兴趣的鸿蒙文章

harmony 鸿蒙JS Service Widget UI Components

harmony 鸿蒙Data Types

harmony 鸿蒙button

harmony 鸿蒙calendar

harmony 鸿蒙chart

harmony 鸿蒙clock

harmony 鸿蒙divider

harmony 鸿蒙image

harmony 鸿蒙input

harmony 鸿蒙progress

  • 所属分类: 后端技术
  • 本文标签: 鸿蒙 软件
  • 版权声明: 本文链接 https://seaxiang.com/blog/adc8de86cfcb4f6dbcb52096d8302035