vue3 - andt封装 Modal.confirm 方法
封装弹框组件
// 封装 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') {
}