HarmonyOS 鸿蒙Next 自定义弹框如何宽度全屏,高度自定义
HarmonyOS 鸿蒙Next 自定义弹框如何宽度全屏,高度自定义
关于HarmonyOS 鸿蒙Next 自定义弹框如何宽度全屏,高度自定义的问题,您也可以访问:https://www.itying.com/category-93-b0.html 联系官网客服。
有要学HarmonyOS AI的同学吗,联系我:https://www.itying.com/goods-1206.html
更多关于HarmonyOS 鸿蒙Next 自定义弹框如何宽度全屏,高度自定义的实战系列教程也可以访问 https://www.itying.com/category-93-b0.html
解决措施
请参考此demo // 自定义弹窗组件1
import router from '@ohos.router'
@CustomDialog export struct MyDialog1 { controller1: CustomDialogController title: string = ‘’
build() { Row() { Column({ space: 10 }) { Text(this.title).fontSize(25) .fontColor(Color.Blue) Flex({ justifyContent: FlexAlign.SpaceAround }) { Button(‘取消’) .onClick(() => { this.controller1.close() }) .backgroundColor(0xffffff) .fontColor(Color.Black) Button(‘确认’) .onClick(() => { // this.controller1.close()
}) .backgroundColor(<span class="hljs-number"><span class="hljs-number">0xffffff</span></span>) .fontColor(Color.Black) } .width(<span class="hljs-string"><span class="hljs-string">'100%'</span></span>) } .width(<span class="hljs-string"><span class="hljs-string">'100%'</span></span>) .backgroundColor(Color.White).height(<span class="hljs-number"><span class="hljs-number">300</span></span>) }
} }
// main页面 @Entry @Component struct Index { @State dialogData: string = ‘’ @State colorTest: Color = Color.Blue dialogController1: CustomDialogController = new CustomDialogController({ builder: MyDialog1({ title: ‘弹窗1’, }), // 弹窗容器样式是否自定义 customStyle: true, offset: { dx: 0, dy: 0 }, alignment: DialogAlignment.Top // 是否允许点击遮障层退出 // autoCancel: false, // 弹窗遮蔽层区域,在遮蔽层区域内的事件不透传,在遮蔽层区域外的事件透传 // maskRect: ({x:0,y:567,width:'100%’,height:220}), // 自定义蒙层颜色 // maskColor: (Color.Yellow) })
confirm(data: string) { this.dialogData = data console.info(recvdialogdata:${data}) // 获取弹窗输入的信息 }
// 在自定义组件即将析构销毁时将dialogController置空 aboutToDisappear() { // 将dialogController置空 // this.dialogController1 = null }
build() { Row() { Column({ space: 10 }) { Text(‘这是一个弹窗的测试’) .fontSize(25).margin(20).fontColor(0x3399FF) Button(‘点击打开弹窗’) .onClick(() => { this.dialogController1.open() }) }.width(‘100%’) }.height(‘100%’).backgroundColor(Color.White) } }
<button style="position: absolute; padding: 4px 8px 0px; cursor: pointer; top: 8px; right: 8px; font-size: 14px;">复制</button>
运行不了啊
有要学HarmonyOS AI的同学吗,联系我:https://www.itying.com/goods-1206.html