var b = null;
var data = 0;
function a() {
var t = b = new Date().getTime();
data += 1;
return new Promise(function(r) {
setTimeout(function() {
r(t, data);
}, 2000);
})
}
function p() {
a().then((t, d) => {
if (t === b) {console.log(d)}
})
}
原文:https://www.cnblogs.com/youyouluo/p/12043504.html