需求的场景是弹出Popup,Popup弹窗内部有提示内容和按钮,期望:
@Entry @Component struct ClosePopupExample { @State customPopup: boolean = false; // popup构造器定义弹框内容 @Builder popupBuilder() { Column({ space: 16 }) { Text(`Custom Popup`); Text('Close') .fontColor('#0a59f7') .onClick(() => { this.customPopup = !this.customPopup; }); } .width(300) .borderRadius(1) .padding({ top: 16, bottom: 16 }); } build() { Column() { Row() { }.width('100%').height(0) .bindPopup(this.customPopup, { builder: this.popupBuilder, placement: Placement.Top, radius: 32, shadow: { radius: 0 }, mask: { color: '#33000000' }, showInSubWindow: false, enableArrow: false, autoCancel: true, onStateChange: (e) => { if (!e.isVisible) { this.customPopup = false; } } }); Button('CustomPopupOptions') .onClick(() => { this.customPopup = !this.customPopup; }); } .justifyContent(FlexAlign.Center) .width('100%').height('100%'); } }