提交 f00719bd 编写于 作者: G guozejun

Add recycle code case.

Signed-off-by: Nguozejun <guozejun@huawei.com>
Change-Id: Ibd66852b523897e27e5debcfdad41cc5e08919d7
上级 5e302dd6
......@@ -127,6 +127,50 @@ onRecycle?(params: { [key: string]: unknown }): void
| ------ | -------------------------- | -------------------- |
| params | { [key: string]: unknown } | 自定义组件的构造参数 |
```ts
// xxx.ets
@Entry
@Component
struct Index {
@State message: string = 'Hello World'
@State switch: boolean = true
build() {
Column() {
Button(this.message)
.fontSize(50)
.fontWeight(FontWeight.Bold)
.onClick(() => {
this.switch = !this.switch
})
if (this.switch) {
Child()
}
}
.height("100%")
.width('100%')
}
}
@Recycle
@Component
struct Child {
onRecycle(params) {
console.info("Recycle Child")
}
build() {
Column() {
Text("Child Component")
.fontSize(20)
}
.borderWidth(2)
.height(100)
}
}
```
## LayoutChild<sup>9+</sup>
子组件布局信息。
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册