• Home
  • Line#
  • Scopes#
  • Navigate#
  • Raw
  • Download
1# 边框设置
2
3设置组件边框样式。
4
5>  **说明:**
6>
7>  从API Version 7开始支持。后续版本如有新增内容,则采用上角标单独标记该内容的起始版本。
8
9
10## 属性
11
12
13| 名称 | 参数类型 | 描述 |
14| -------- | -------- | -------- |
15| border | {<br/>width?:&nbsp;[Length](ts-types.md#length),<br/>color?:&nbsp;[ResourceColor](ts-types.md#resourcecolor),<br/>radius?:&nbsp;[Length](ts-types.md#length),<br/>style?:&nbsp;[BorderStyle](ts-appendix-enums.md#borderstyle)<br/>} | 统一边框样式设置接口。 |
16| borderStyle | [BorderStyle](ts-appendix-enums.md#borderstyle) | 设置元素的边框样式。<br/>默认值:BorderStyle.Solid |
17| borderWidth | [Length](ts-types.md#length) | 设置元素的边框宽度。 |
18| borderColor | [ResourceColor](ts-types.md#resourcecolor) | 设置元素的边框颜色。 |
19| borderRadius | [Length](ts-types.md#length) | 设置元素的边框圆角半径。 |
20
21
22
23## 示例
24
25```ts
26// xxx.ets
27@Entry
28@Component
29struct BorderExample {
30  build() {
31    Flex({ justifyContent: FlexAlign.SpaceAround, alignItems: ItemAlign.Center }) {
32      // 线段
33      Text('dashed')
34        .borderStyle(BorderStyle.Dashed).borderWidth(5).borderColor(0xAFEEEE).borderRadius(10)
35        .width(120).height(120).textAlign(TextAlign.Center).fontSize(16)
36      // 点线
37      Text('dotted')
38        .border({ width: 5, color: 0x317AF7, radius: 10, style: BorderStyle.Dotted })
39        .width(120).height(120).textAlign(TextAlign.Center).fontSize(16)
40    }.width('100%').height(150)
41  }
42}
43```
44
45![zh-cn_image_0000001219982705](figures/zh-cn_image_0000001219982705.gif)
46