第一步:自定义UI样式
@State customPopup: boolean = false
// popup构造器定义弹框内容
@Builder
popupBuilder() {
Column({ space: 2 }) {
Text("删除辅助安全域")
.margin({ top: 15, left: 10 })
.onClick(() => {
this.customDialogController.open()
})
Text("清楚缓存")
.margin({ top: 20, left: 10 })
.onClick(() => {
this.customDialogController.open()
})
}.width(200).height(100).padding(5)
.alignItems(HorizontalAlign.Start)
}
第二步:调用Popup
Text("......")
.height(50)
.margin({ right: 50 })
.onClick(() => {
this.customPopup = !this.customPopup
})
.bindPopup(this.customPopup, {
builder: this.popupBuilder, //气泡的内容
placement: Placement.Bottom, //气泡的弹出位置
popupColor: Color.Pink, //气泡的背景色
onStateChange: (e) => {
console.info(JSON.stringify(e.isVisible))
if (!e.isVisible) {
this.customPopup = false
}
}
})