现在这个是之前封装的alter弹窗完善版,可以传入标题,内容以及点击取消,确定的回调。
/**
* [确认框]
* @param {string} message [消息]
* @param {string} title [标题]
* @param {any[]) => void} confirmHandler [确认操作]
* @param confirmText confirmText[确定键的文字]
* @param {any[]) => void} cancelHandler [取消操作]
*/
alertConfirm(message: string, title?: string, confirmText?: string, confirmHandler?: (...args: any[]) => void,
cancelHandler?: (...args: any[]) => void)
{
let confirm = this.alertCtrl.create({
title: title ? title : "提示",
message: message,
buttons:[
{
text:"取消",
role: "cancel",
handler: () => {
if(cancelHandler) cancelHandler();
}
},
{
text: confirmText || "确定",
handler: () => {
if(confirmHandler) confirmHandler();
}
}
],
cssClass: "alert"
});
confirm.present();
}
接下来是使用方法
this.appService.alertConfirm("要退出登陆吗?","提示","退出",()=>{
console.log("点击了确定");
},()=>{
console.log("点击了取消");
});
网友评论