初涉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');
}

猜你喜欢

转载自www.cnblogs.com/dkplus/p/8950105.html