From 9400a61fd54fa0f28f051e8b1f7dad837c773693 Mon Sep 17 00:00:00 2001 From: Leon Xu <6479451-leonxu260@users.noreply.gitlab.com> Date: Fri, 1 Oct 2021 20:40:11 -0700 Subject: [PATCH] doc: add set some time section --- source/_posts/异步执行.md | 9 +++++++++ 1 file changed, 9 insertions(+) diff --git a/source/_posts/异步执行.md b/source/_posts/异步执行.md index 2bd00b4..54898db 100644 --- a/source/_posts/异步执行.md +++ b/source/_posts/异步执行.md @@ -94,4 +94,13 @@ verifyPizza(); eatPizza(); // twiddle thumbs payForPizza(); +``` +# 定时间 +```javascript +function orderExecutor(resolve, reject) { // reject not required here + console.log('making our pizza...'); + setTimeout(resolve, 5000); +} +let orderPizza = new Promise(orderExecutor); +orderPizza.then(function () { console.log('eating pizza!'); }); ``` \ No newline at end of file