可以通过以下方式设置 CustomDialog 的宽度:使用模态转场实现。示例代码:@CustomDialog struct CustomDialogExample { cancel: () => void = () => { console.info('Callback when the first button is clicked') } confirm: () => void = () => { console.info('Callback when the second button is clicked') } controller: CustomDialogController = new CustomDialogController({ builder: CustomDialogExample({ cancel: this.cancel, confirm: this.confirm, }), autoCancel: true, customStyle: true, }) @State showFlag: Visibility = Visibility.Visible; build() { Column() { Text('我是内容') .fontSize(20) .margin({ top: 10, bottom: 10 }) .backgroundColor('#FFFFFF') .height(200) .width('100%') .margin({ top: 600 }) } .width('100%') .height('100%') .onClick(() => { this.showFlag = Visibility.Hidden setTimeout(() => { this.controller.close() } } } }另外,通过 CustomDialogController(value: CustomDialogControllerOptions) ,Option 属性支持 customStyle、gridCount。customStyle 设为 false ,同时设置 gridCount 栅格数;customStyle 设为 true ,大小由子组件决定。
可以通过以下方式设置 CustomDialog 的宽度:
使用模态转场实现。示例代码:
另外,通过 CustomDialogController(value: CustomDialogControllerOptions) ,Option 属性支持 customStyle、gridCount。customStyle 设为 false ,同时设置 gridCount 栅格数;customStyle 设为 true ,大小由子组件决定。