鍍金池/ 問答/HTML/ antd中的Modal.confirm 必須要用Promise才能延遲加載么

antd中的Modal.confirm 必須要用Promise才能延遲加載么

antd的延遲加載必須得用Promise才能實現(xiàn)么

以下是官方里面的demo

https://codesandbox.io/s/rr78lq91yq

圖片描述

import { Modal, Button } from 'antd';
const confirm = Modal.confirm;

function showConfirm() {
  confirm({
    title: 'Do you want to delete these items?',
    content: 'When clicked the OK button, this dialog will be closed after 1 second',
    onOk() {
      return new Promise((resolve, reject) => {
        setTimeout(Math.random() > 0.5 ? resolve : reject, 1000);
      }).catch(() => console.log('Oops errors!'));
    },
    onCancel() {},
  });
}
回答
編輯回答
女流氓

官方文檔里有例子
https://ant.design/components...

2017年10月9日 13:14