封裝彈框元件
// 封裝 Modal.confirm 方法
function confirm(title: string, content: string, okText: string = '確定', cancelText: string = '取消') {
return new Promise<string | null>((resolve) => {
Modal.confirm({
title,
content,
okText,
cancelText,
onOk() {
resolve('ok');
},
onCancel() {
resolve('cancel');
},
});
});
}
使用js
let cusNameResult = await confirm('提示', '當前客戶存在未停止的銷售未交單,是否繼續儲存?');
if (cusNameResult === 'ok') {
}