d
k
p
l
u
s

初涉yield

function* a(i) {
  console.log('here we go');
  yield i;
  // 必须有*,不然b会作为返回值,而不是执行
  yield* b(i);
  yield i+10;
  console.log('really end');
}
function* b(i) {
  console.log('oh change');
  yield i+1;
  yield i+2;
  yield i+3;
  console.log('change end');
}
posted @ 2018-04-26 10:45  dkplus  阅读(125)  评论(0编辑  收藏  举报