{ let a = function*() { yield new Promise((resolve, reject) => { setTimeout(() => { resolve({ code: 0 }); }, 500); }); }; let b = function() { let g = a(); let s = g.next(); s.value.then(function(d) { if (d.code != 0) { setTimeout(() => { console.log('wait'); b(); }, 500); } else { console.log('code为0,成功'); } }); }; b(); }