未验证 提交 e28bac74 编写于 作者: L luoying_ace 提交者: Gitee

update zh-cn/application-dev/reference/arkui-ts/ts-universal-events-show-hide.md.

Signed-off-by: Nluoying_ace <luoying19@huawei.com>
上级 53829f71
...@@ -19,30 +19,36 @@ ...@@ -19,30 +19,36 @@
```ts ```ts
// xxx.ets // xxx.ets
import prompt from '@system.prompt' import prompt from '@system.prompt';
@Entry @Entry
@Component @Component
struct AppearExample { struct AppearExample {
@State isShow: boolean = true @State isShow: boolean = true;
private myText: string = 'Text for onAppear' @State changeAppear: string = 'Hide Text';
private changeAppear: string = 'Hide Text' private myText: string = 'Text for onAppear';
build() { build() {
Column() { Column() {
Button(this.changeAppear) Button(this.changeAppear)
.onClick(() => { .onClick(() => {
this.isShow = !this.isShow this.isShow = !this.isShow;
}).margin(3).backgroundColor(0x2788D9) }).margin(15)
if (this.isShow) { if (this.isShow) {
Text(this.myText) Text(this.myText).fontSize(26).fontWeight(FontWeight.Bold)
.onAppear(() => { .onAppear(() => {
this.changeAppear = 'Show Text' this.changeAppear = 'Hide Text';
prompt.showToast({ message: 'The text is shown', duration: 2000 }) prompt.showToast({
message: 'The text is shown',
duration: 2000
})
}) })
.onDisAppear(() => { .onDisAppear(() => {
this.changeAppear = 'Hide Text' this.changeAppear = 'Show Text';
prompt.showToast({ message: 'The text is hidden', duration: 2000 }) prompt.showToast({
message: 'The text is hidden',
duration: 2000
})
}) })
} }
}.padding(30).width('100%') }.padding(30).width('100%')
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册