企业🤖AI智能体构建引擎,智能编排和调试,一键部署,支持知识库和私有化部署方案 广告
1.创建promise ~~~ const promise = new Promise((resolve,reject)=>{ // pending 进行中 // fulfilled 已成功 // rejected 已失败 wx.getSystemInfo({ success: function(res) { resolve(res); }, fail:error=>{ reject(error); } }) }) //只要new Promise()那么promise就在进行中 //如果将进行中的代码,调用resolve()或reject()那么promise的状态就凝固了 ~~~ 2.使用then调用promise成功或失败的状态 ~~~ promise.then(res=>{ console.log(res); },err=>{ console.log(err); }) ~~~