https://developer.huawei.com/consumer/cn/doc/harmonyos-references-V5/ts-universal-attributes-sheet-transition-V5\#sheetoptions半模态bindSheet每次弹出,其内容都会重新绘制,有没有参数设置能让其保持上次关闭前的状态?
半模态的参数直接使用@State修饰,下次打开还是上次的参数。demo:// xxx.ets @Entry @Component struct SheetTransitionExample { @State isShow:boolean = false @State isShow2:boolean = false @State sheetHeight:number = 300; @State text:string='xxxxx' @Builder myBuilder() { Column() { Text(this.text) .margin(10) .fontSize(20) .onClick(()=>{ this.sheetHeight = 500; this.text='wewewewa' }) } .width('100%') .height('100%') } build() { Column() { Button("transition modal 1") .onClick(() => { this.isShow = true }) .fontSize(20) .margin(10) .bindSheet($$this.isShow, this.myBuilder(), { height: this.sheetHeight, backgroundColor: Color.Green, onAppear: () => {console.log("BindSheet onAppear.")}, onDisappear: () => {console.log("BindSheet onDisappear.")} }) } .justifyContent(FlexAlign.Center) .width('100%') .height('100%') } }
半模态的参数直接使用@State修饰,下次打开还是上次的参数。
demo: