es6 Generator函数
<script type="text/javascript"> function* myGenerator(){ console.log('业务逻辑A') let result=yield 'hello' console.log(result) console.log('业务逻辑B') yield 'world' console.log('执行完了') } let mg=myGenerator(); console.log(mg.next()) console.log(mg.next('hehe')) console.log(mg.next()) </script>