示例参考://Index.ets import { router } from '@kit.ArkUI' @Entry @Component struct Index { @State message:string='' @State isShow: boolean = false onPageShow(): void { this.isShow=true } onPageHide(): void { this.isShow=false } build() { Column() { if (this.isShow){ TextInput({ text:this.message }) .width('95%') .height(40) .margin(20) .type(InputType.Password) .onChange((value)=>this.message=value) .maxLength(9) // .defaultFocus(true) // .showPasswordIcon(true) } Button('按钮').onClick(() => { router.pushUrl({ url: "pages/demo" }) }) }.width('100%') } } //demo.ets import { router } from '@kit.ArkUI'; @Entry @Component struct Demo { @State message: string = 'Hello World'; build() { RelativeContainer() { Column(){ Button('按钮').onClick(() => { router.back({ url: "pages/Index" }) }) } } .height('100%') .width('100%') } }
示例参考: