📜  可取消函数 - Javascript 代码示例

📅  最后修改于: 2022-03-11 15:01:18.194000             🧑  作者: Mango

代码示例1
let resp = await new Promise(function(resolve, reject) {
    // simulating time consuming process
    setTimeout(() => resolve('Promise RESOLVED !'), 3000);
    // hit a button to cancel the promise
    $('#btn').click(() => resolve('Promise CANCELED !'));
});