// Promise 对象,可以保存状态
    //Promise 第一步
    // 异步代码 写在 Promise的函数中  第二步
    const promise = new Promise((resolve, reject) => {
      // Promise一共有三种状态: pending fulfilled rejected
      //                         进行中   已成功   已失败
      // 获取系统信息
      wx.getSystemInfo({
        success: res => resolve(res),
        fail: error => reject(error)
      })
    })

    // 第三步:调用promise,可以调用两个回调函数,第一个是成功的,第二个是失败的
    promise.then(
      res=>console.log(res),
      error=>console.log(error)
    )

 

相关文章:

  • 2022-12-23
  • 2022-12-23
  • 2022-12-23
  • 2022-02-21
  • 2021-05-26
  • 2021-09-18
  • 2022-12-23
  • 2021-11-03
猜你喜欢
  • 2021-03-31
  • 2021-11-18
  • 2021-11-07
  • 2021-10-06
相关资源
相似解决方案