中国优质的IT技术网站
专业IT技术创作平台
IT职业在线教育平台
HarmonyOS 如何在bindsheet内的mybuilder里面传一个自定义全局的Component?
微信扫码分享
import {Page_text} from './Page_text' @Entry @Component struct Page_7075 { @State isShow:boolean = false @Builder myBuilder() { Column() { Button("content1") .margin(10) .fontSize(20) Page_text() Button("content2") .margin(10) .fontSize(20) } .width('100%') } build() { Column() { Button("transition modal 1") .onClick(() => { this.isShow = true }) .fontSize(20) .margin(10) .bindSheet($$this.isShow, this.myBuilder(),{ detents:[SheetSize.MEDIUM,SheetSize.LARGE,200], backgroundColor:Color.Gray, blurStyle:BlurStyle.Thick, showClose:true, title:{title:"title", subtitle:"subtitle"}, preferType: SheetType.CENTER, shouldDismiss:((sheetDismiss: SheetDismiss)=> { console.log("bind sheet shouldDismiss") sheetDismiss.dismiss() }) }) } .justifyContent(FlexAlign.Start) .width('100%') .height('100%') } } @Entry @Component export struct Page_text { @State message: string = 'Hello World'; build() { RelativeContainer() { Text(this.message) .id('HelloWorld') .fontSize(50) .fontWeight(FontWeight.Bold) .alignRules({ center: { anchor: '__container__', align: VerticalAlign.Center }, middle: { anchor: '__container__', align: HorizontalAlign.Center } }) } .height('100%') .width('100%') } }