编辑代码

async function main1() {
  await new Promise(resolve => {
    setTimeout(() => {
      resolve()
    })
  })
  console.log('main1')
  await child11()
  await child12()
  await child13()
}

async function child11() {
  await new Promise(resolve => {
    setTimeout(() => {
      resolve()
    })
  })
  console.log('child11')
}

async function child12() {
  await new Promise(resolve => {
    setTimeout(() => {
      resolve()
    })
  })
  console.log('child12')
}

async function child13() {
  await new Promise(resolve => {
    setTimeout(() => {
      resolve()
    })
  })
  console.log('child13')
}

async function main2() {
  await new Promise(resolve => {
    setTimeout(() => {
      resolve()
    })
  })
  console.log('main2')
  await child21()
  await child22()
  await child23()
}

async function child21() {
  await new Promise(resolve => {
    setTimeout(() => {
      resolve()
    })
  })
  console.log('child21')
}

async function child22() {
  await new Promise(resolve => {
    setTimeout(() => {
      resolve()
    })
  })
  console.log('child22')
}

async function child23() {
  await new Promise(resolve => {
    setTimeout(() => {
      resolve()
    })
  })
  console.log('child23')
}


(async () => {
  await main1()
  await main2()
})()