function test(resolve, reject) { var timeOut = Math.random() 2; log('set timeout to: ' + timeOut + ' seconds.'); setTimeout(function () { if (timeOut < 1) { log('call resolve()...'); resolve('200 OK'); } else { log('call reject()...'); reject('timeout in ' + timeOut + ' seconds.'); } }, timeOut 1000); }
<
少年你的“2”前面Math.random()后面掉了一个乘号*呀。
Sign in to make a reply
烛龙一现
function test(resolve, reject) { var timeOut = Math.random() 2; log('set timeout to: ' + timeOut + ' seconds.'); setTimeout(function () { if (timeOut
<
; 1) { log('call resolve()...'); resolve('200 OK'); } else { log('call reject()...'); reject('timeout in ' + timeOut + ' seconds.'); } }, timeOut 1000); }