ts-basic-components-divider.md 2.1 KB
Newer Older
Z
zengyawen 已提交
1 2
# Divider

Z
zengyawen 已提交
3 4
提供分隔器组件,分隔不同内容块/内容元素。

G
gmy 已提交
5 6 7
>  **说明:**
>
>  该组件从API Version 7开始支持。后续版本如有新增内容,则采用上角标单独标记该内容的起始版本。
Z
zengyawen 已提交
8

Z
zengyawen 已提交
9 10

## 子组件
Z
zengyawen 已提交
11 12 13



Z
zengyawen 已提交
14 15 16 17 18 19 20

## 接口

Divider()

## 属性

G
gmy 已提交
21 22
除支持[通用属性](ts-universal-attributes-size.md)外,还支持以下属性:

H
hebingxue 已提交
23 24 25 26
| 名称      | 参数类型         | 描述        |
| ----------- | ---------- | ------------------ |
| vertical    | boolean | 使用水平分割线还是垂直分割线。false:水平分割线;true:垂直分割线。<br/>默认值:false |
| color       | [ResourceColor](ts-types.md#resourcecolor) | 分割线颜色。 |
G
gmy 已提交
27
| strokeWidth | number&nbsp;\|&nbsp;string | 分割线宽度。<br/>默认值:1 |
H
hebingxue 已提交
28
| lineCap     | [LineCapStyle](ts-appendix-enums.md#linecapstyle) | 分割线的端点样式。<br/>默认值:LineCapStyle.Butt |
Z
zengyawen 已提交
29 30 31


## 事件
Z
zengyawen 已提交
32 33 34

不支持通用事件。

Z
zengyawen 已提交
35 36

## 示例
Z
zengyawen 已提交
37

H
geshi  
HelloCrease 已提交
38 39
```ts
// xxx.ets
Z
zengyawen 已提交
40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67
@Entry
@Component
struct DividerExample {
  build() {
    Flex({ direction: FlexDirection.Column, alignItems: ItemAlign.Start, justifyContent: FlexAlign.SpaceBetween }) {
      Text('Horizontal divider').fontSize(9).fontColor(0xCCCCCC)
      Row().width('100%').height(40).backgroundColor(0xF1F3F5)
      Divider()
      Row().width('100%').height(40).backgroundColor(0xF1F3F5)

      Text('Vertical divider').fontSize(9).fontColor(0xCCCCCC)
      Flex({ alignItems: ItemAlign.Center, wrap: FlexWrap.Wrap }) {
        Text('bravery')
        Divider().vertical(true).margin(20).height(15)
        Text('effort')
        Divider().vertical(true).margin(20).height(15)
        Text('upward')
      }.width(250)

      Text('Custom Styles').fontSize(9).fontColor(0xCCCCCC)
      Row().width('100%').height(40).backgroundColor(0xF1F3F5)
      Divider().vertical(false).strokeWidth(5).color(0x2788D9).lineCap(LineCapStyle.Round)
      Row().width('100%').height(40).backgroundColor(0xF1F3F5)
    }.width('100%').height(350).padding({ left: 35, right: 35, top: 35 })
  }
}
```

Z
zengyawen 已提交
68
![zh-cn_image_0000001174422926](figures/zh-cn_image_0000001174422926.png)