HarmonyOS 如何在bindsheet内的mybuilder里面传一个自定义全局的Component?

HarmonyOS  如何在bindsheet内的mybuilder里面传一个自定义全局的Component?


HarmonyOS
2024-09-26 13:21:52
浏览
收藏 0
回答 1
回答 1
按赞同
/
按时间
zxjiu
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%')  
  }  
}
  • 1.
  • 2.
  • 3.
  • 4.
  • 5.
  • 6.
  • 7.
  • 8.
  • 9.
  • 10.
  • 11.
  • 12.
  • 13.
  • 14.
  • 15.
  • 16.
  • 17.
  • 18.
  • 19.
  • 20.
  • 21.
  • 22.
  • 23.
  • 24.
  • 25.
  • 26.
  • 27.
  • 28.
  • 29.
  • 30.
  • 31.
  • 32.
  • 33.
  • 34.
  • 35.
  • 36.
  • 37.
  • 38.
  • 39.
  • 40.
  • 41.
  • 42.
  • 43.
  • 44.
  • 45.
  • 46.
  • 47.
  • 48.
  • 49.
  • 50.
  • 51.
  • 52.
  • 53.
  • 54.
  • 55.
  • 56.
  • 57.
  • 58.
  • 59.
  • 60.
  • 61.
  • 62.
  • 63.
  • 64.
  • 65.
分享
微博
QQ
微信
回复
2024-09-26 15:33:29


相关问题
如何在全局实现一个自定义dialog弹窗
3640浏览 • 1回复 待解决
如何在自定义函数中创建一个UI组件
2543浏览 • 1回复 待解决
HarmonyOS一个自定义tabs冲突
925浏览 • 1回复 待解决
HarmonyOS bindSheet如何自定义圆角
1001浏览 • 1回复 待解决
如何实现一个自定义样式toast提示
2723浏览 • 1回复 待解决
如何实现一个自定义询问框
1155浏览 • 1回复 待解决
如何添加一个自定义代码文件夹
1192浏览 • 1回复 待解决
如何自定义Component 属性
15982浏览 • 3回复 待解决