promise链式执行顺序

new Promise((resolve, reject) => {
  console.log("promise")
  resolve()
 })
 .then(() => {	// 执行.then的时候生成一个promise是给最后一个.then的
  console.log("then1")
    new Promise((resolve, reject) => {
    console.log("then1promise")
    resolve()
    })
    .then(() => {// 执行这个.then的时候,生成的promise是下面一个then的
    console.log("then1then1")
    })
    .then(() => {
    console.log("then1then2")
    })
  })
  .then(() => {
  // 这个
  console.log("then2")
  })

 执行结果


promise
then1
then1promise
then1then1
then2
then1then2

猜你喜欢

转载自blog.csdn.net/weixin_69811594/article/details/130286917