leiyanting

导航

 
        let p = new Promise((resolve, reject) => {
            //1. resolve 函数
            resolve('ok'); // pending   => fulfilled (resolved) 成功状态
            //2. reject 函数
            reject("error");// pending  =>  rejected 失败状态
            //3. 抛出错误
            throw '出问题了'; //失败状态
        });

        console.log(p);

 

posted on 2021-10-12 19:13  leiyanting  阅读(58)  评论(0编辑  收藏  举报