提交 9853a294 编写于 作者: T tianyu

border explain

Signed-off-by: Ntianyu <tianyu55@h-partners.com>
上级 7d041340
...@@ -94,10 +94,10 @@ ...@@ -94,10 +94,10 @@
<div class="container"> <div class="container">
<svg> <svg>
<text y="50" font-size="30" fill="blue"> <text y="50" font-size="30" fill="blue">
text attribute x|opacity|rotate
<animate attributeName="x" from="100" by="400" dur="3s" repeatCount="indefinite"></animate> <animate attributeName="x" from="100" by="400" dur="3s" repeatCount="indefinite"></animate>
<animate attributeName="opacity" from="0.01" to="0.99" dur="3s" repeatCount="indefinite"></animate> <animate attributeName="opacity" from="0.01" to="0.99" dur="3s" repeatCount="indefinite"></animate>
<animate attributeName="rotate" from="0" to="360" dur="3s" repeatCount="indefinite"></animate> <animate attributeName="rotate" from="0" to="360" dur="3s" repeatCount="indefinite"></animate>
text attribute x|opacity|rotate
</text> </text>
</svg> </svg>
</div> </div>
......
...@@ -19,7 +19,7 @@ ...@@ -19,7 +19,7 @@
| 名称 | 参数类型 | 默认值 | 描述 | | 名称 | 参数类型 | 默认值 | 描述 |
| -------- | -------- | -------- | -------- | | ------------ | ------------- | ----------------------- | ------------------------ |
| border | BorderOptions | - | 统一边框样式设置接口。 | | border | BorderOptions | - | 统一边框样式设置接口。 |
| borderStyle | BorderStyle | &nbsp;BorderStyle.Solid | 设置元素的边框样式。 | | borderStyle | BorderStyle | &nbsp;BorderStyle.Solid | 设置元素的边框样式。 |
| borderWidth | Length | 0 | 设置元素的边框宽度。 | | borderWidth | Length | 0 | 设置元素的边框宽度。 |
...@@ -27,13 +27,36 @@ ...@@ -27,13 +27,36 @@
| borderRadius | Length | 0 | 设置元素的边框圆角半径。 | | borderRadius | Length | 0 | 设置元素的边框圆角半径。 |
- BorderOptions属性说明 - BorderOptions属性说明
| 参数名称 | 参数类型 | 默认值 | 必填 | 参数描述 | | 参数名称 | 参数类型 | 默认值 | 必填 | 参数描述 |
| -------- | -------- | -------- | -------- | -------- | | -------- | ------------------------------------------------------------ | ----------------- | ---- | ---------- |
| width | [Length](../../ui/ts-types.md#长度类型) | 0 | 否 | 边框宽度。 | | width | [Length](../../ui/ts-types.md#长度类型)\|EdgeWidth<sup>9+</sup> | 0 | 否 | 边框宽度。 |
| color | [ResourceColor](../../ui/ts-types.md) | 'Black' | 否 | 边框颜色。 | | color | [ResourceColor](../../ui/ts-types.md)\|EdgeColor<sup>9+</sup> | 'Black' | 否 | 边框颜色。 |
| radius | [Length](../../ui/ts-types.md#长度类型)\| EdgeRadiuses<sup>9+</sup> | 0 | 否 | 边框角度。 | | radius | [Length](../../ui/ts-types.md#长度类型)\| EdgeRadiuses<sup>9+</sup> | 0 | 否 | 边框角度。 |
| style | BorderStyle | BorderStyle.Solid | 否 | 边框样式。 | | style | BorderStyle\|EdgeStyle<sup>9+</sup> | BorderStyle.Solid | 否 | 边框样式。 |
- EdgeWidth<sup>9+</sup>对象说明
引入该对象时,至少传入一个参数。
| 名称 | 参数类型 | 必填 | 默认值 | 描述 |
| ------ | -------- | ---- | ------ | -------------- |
| left | length | 否 | 0 | 左侧边框宽度。 |
| right | length | 否 | 0 | 右侧边框宽度。 |
| top | length | 否 | 0 | 上侧边框宽度。 |
| bottom | length | 否 | 0 | 下侧边框宽度。 |
- EdgeColor<sup>9+</sup>对象说明
引入该对象时,至少传入一个参数。
| 名称 | 参数类型 | 必填 | 默认值 | 描述 |
| ------ | ------------------------------------- | ---- | ------- | -------------- |
| left | [ResourceColor](../../ui/ts-types.md) | 否 | 'Black' | 左侧边框颜色。 |
| right | [ResourceColor](../../ui/ts-types.md) | 否 | 'Black' | 右侧边框颜色。 |
| top | [ResourceColor](../../ui/ts-types.md) | 否 | 'Black' | 上侧边框颜色。 |
| bottom | [ResourceColor](../../ui/ts-types.md) | 否 | 'Black' | 下侧边框颜色。 |
- EdgeRadiuses<sup>9+</sup>对象说明 - EdgeRadiuses<sup>9+</sup>对象说明
...@@ -46,12 +69,21 @@ ...@@ -46,12 +69,21 @@
| bottomLeft | length | 否 | 0 | 左下角圆角半径。 | | bottomLeft | length | 否 | 0 | 左下角圆角半径。 |
| bottomRight | length | 否 | 0 | 右下角圆角半径。 | | bottomRight | length | 否 | 0 | 右下角圆角半径。 |
- EdgeStyle<sup>9+</sup>对象说明
引入该对象时,至少传入一个参数。
| 名称 | 参数类型 | 必填 | 默认值 | 描述 |
| ------ | ----------- | ---- | ----------------- | -------------- |
| left | BorderStyle | 否 | BorderStyle.Solid | 左侧边框样式。 |
| right | BorderStyle | 否 | BorderStyle.Solid | 右侧边框样式。 |
| top | BorderStyle | 否 | BorderStyle.Solid | 上侧边框样式。 |
| bottom | BorderStyle | 否 | BorderStyle.Solid | 下侧边框样式。 |
- BorderStyle枚举说明 - BorderStyle枚举说明
| 名称 | 描述 | | 名称 | 描述 |
| -------- | -------- | | ------ | ----------------------------------------------- |
| Dotted | 显示为一系列圆点,圆点半径为borderWidth的一半。 | | Dotted | 显示为一系列圆点,圆点半径为borderWidth的一半。 |
| Dashed | 显示为一系列短的方形虚线。 | | Dashed | 显示为一系列短的方形虚线。 |
| Solid | 显示为一条实线。 | | Solid | 显示为一条实线。 |
...@@ -65,20 +97,33 @@ ...@@ -65,20 +97,33 @@
@Component @Component
struct BorderExample { struct BorderExample {
build() { build() {
Column() {
Flex({ justifyContent: FlexAlign.SpaceAround, alignItems: ItemAlign.Center }) { Flex({ justifyContent: FlexAlign.SpaceAround, alignItems: ItemAlign.Center }) {
// 线段 // 线段
Text('dashed') Text('dashed')
.borderStyle(BorderStyle.Dashed).borderWidth(5).borderColor(0xAFEEEE).borderRadius(10) .borderStyle(BorderStyle.Dashed).borderWidth(5).borderColor(0xAFEEEE).borderRadius(10)
.width(120).height(120).textAlign(TextAlign.Center).fontSize(16) .width(120).height(120).textAlign(TextAlign.Center).fontSize(16)
Text('dashed')
.borderStyle(BorderStyle.Dashed).borderWidth(5).borderColor(0xAFEEEE)
.borderRadius({ topLeft: 10, topRight: 20, bottomLeft: 30, bottomRight: 60 })
.width(120).height(120).textAlign(TextAlign.Center).fontSize(16)
// 点线 // 点线
Text('dotted') Text('dotted')
.border({ width: 5, color: 0x317AF7, radius: 10, style: BorderStyle.Dotted }) .border({ width: 5, color: 0x317AF7, radius: 10, style: BorderStyle.Dotted })
.width(120).height(120).textAlign(TextAlign.Center).fontSize(16) .width(120).height(120).textAlign(TextAlign.Center).fontSize(16)
}.width('100%').height(150) }.width('100%').height(150)
Text('.border')
.fontSize(50)
.width(300)
.height(300)
.border({
width: { left: '5lpx', right: '10lpx', top: '20lpx', bottom: '30lpx' },
color: { left: '#e3bbbb', right: Color.Blue, top: Color.Red, bottom: Color.Green },
radius: { topLeft: 10, topRight: 20, bottomLeft: 40, bottomRight: 80 },
style: {
left: BorderStyle.Dotted,
right: BorderStyle.Dotted,
top: BorderStyle.Solid,
bottom: BorderStyle.Dashed
}
}).textAlign(TextAlign.Center)
}
} }
} }
``` ```
......
...@@ -70,42 +70,55 @@ ...@@ -70,42 +70,55 @@
## 示例 ## 示例
``` ```
class ClassA {
public a:number
constructor(a: number) {
this.a = a
}
}
@Entry @Entry
@Component @Component
struct Parent { struct Parent {
@State parentState: ClassA = new ClassA() @State parentState: ClassA = new ClassA(1)
build() { build() {
Row() { Column() {
CompA({aState: new ClassA, aLink: $parentState}) // valid Flex({ justifyContent: FlexAlign.Start, alignItems: ItemAlign.Center }) {
CompA({aLink: $parentState}) // valid CompA({ astate: new ClassA(2), aLink: $parentState })
CompA() // invalid, @Link aLink remains uninitialized }
CompA({aLink: new ClassA}) // invalid, @Link aLink must be a reference ($) to either @State or @Link variable Flex({ justifyContent: FlexAlign.Start, alignItems: ItemAlign.Center }) {
CompA({ aLink: $parentState })
}
Flex({ justifyContent: FlexAlign.Start, alignItems: ItemAlign.Center }) {
CompA({ astate: new ClassA(3), aLink: $parentState })
}
} }
} }
} }
@Component @Component
struct CompA { struct CompA {
@State aState: boolean = false // must initialize locally @State aState: any = false
@Link aLink: ClassA // must not initialize locally @Link aLink: ClassA
build() { build() {
Row() { Column() {
CompB({bLink: $aLink, // valid init a @Link with reference of another @Link, CompB({ bLink: $aLink, bProp: this.aState })
bProp: this.aState}) // valid init a @Prop with value of a @State CompB({ bLink: $aState, bProp: false })
CompB({aLink: $aState, // invalid: type mismatch expected ref to ClassA, provided reference to boolean
bProp: false}) // valid init a @Prop by constants value
} }
} }
} }
@Component @Component
struct CompB { struct CompB {
@Link bLink: ClassA = new ClassA() // invalid, must not initialize locally @Link bLink: ClassA
@Prop bProp: boolean = false // invalid must not initialize locally @Prop bProp: bpplean
build() { build() {
... Flex({ justifyContent: FlexAlign.Start, alignItems: ItemAlign.Center }) {
Text(JSON.stringify(this.bLink.a)).fontSize(30)
Text(JSON.stringify(this.bProp)).fontSize(30).fontColor(Color.Red)
}.margin(10)
} }
} }
``` ```
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册