popup的使用

发布时间:2026/5/18 14:04:17

popup的使用 popup弹出框首先介绍基本使用定义一下状态Localpopup:booleanfalse写入按钮弹出文字Button(popup).bindPopup(this.popup,{message:Hello world,}).onClick((event:ClickEvent){this.popup!this.popup;});进阶加入事件监听Button(popup).bindPopup(this.popup,{message:Hello world,onStateChange:(state){this.getUIContext().getPromptAction().showToast({message:state.isVisible?弹窗已打开:弹窗已关闭,});},}).onClick((event:ClickEvent){this.popup!this.popup;});加入按钮Button(popup).bindPopup(this.popup,{message:Hello world,onStateChange:(state){toastUtil(state.isVisible?show:hidden,this.getUIContext());},primaryButton:{value:ok,action:(){toastUtil(ok,this.getUIContext());},},secondaryButton:{value:cancle,action:(){toastUtil(cancle,this.getUIContext());},},});注意toastUtil(state.isVisible?show:hidden,this.getUIContext());// 方法为下面方法的封装this.getUIContext().getPromptAction().showToast({message:state.isVisible?弹窗已打开:弹窗已关闭,});自定义内容以上为基本的文字展示现在我们来介绍一下如何自定义弹出内容Button(popup).bindPopup(this.popup,{builder:this.PopupBuilder,placement:Placement.Top,// 气泡弹出位置popupColor:Color.Red,// 气泡背景颜色}).onClick((event:ClickEvent){this.popup!this.popup;});

相关新闻