//核心为Promise对象的状态,当处于pending时代码运行,
//到达 filled rejected 进行对应的函数运行
//微信小程序 获取 系统信息实例
const promise = new Promise((resolve,reject)=>{
wx.getSystemInfo({
success: (res) => {
resolve(res)},
fail: (error) => {
reject(error)}
})
})
//then方法传入两个参数 分别运行不同的 代码
promise.then(
(res)=>{
console.log(res)},
(error)=>{
console.log(res)})
},
Promise入门
猜你喜欢
转载自blog.csdn.net/qq_42676042/article/details/106948039
今日推荐
周排行