为了更方便使用的antd的modal组件中的确认框功能,需要注册到全局方法更方便,按如下操作即可// 暴露confirm方法到globalPropertiesapp.config.globalProperties.$confirm = async function (message: string, title: string, options?: any) { return new Promise((resolve, reject) => { let status: null | Number = null; Modal.confirm({ title: title, type: options?.type || 'info', content: message, onOk: () => { status = 1 }, onCancel: () => { status = 0 }, // // eslint-disable-next-line @typescript-eslint/no-empty-function // onCancel: callback2, }); let get= () =>{ setTimeout(() => { if (status !== null) { if (status == 1) { console.log('onOk'); resolve({}); } else { console.log('onCancel'); reject({}); } } else { get(); } }, 10) } get(); }); };