当前位置:网站首页>Scénarios d'utilisation de la promesse
Scénarios d'utilisation de la promesse
2022-06-24 08:23:00 【Nanjing Front End】
1.await && async Mot - clé en attente de la demande
async function test(){
var message = await new Promise((resolve,reject)=>{
setTimeout(function(){
resolve("{message:'hello'}")
},3000)
})
.then(value=>{ return JSON.parse(value) })
.then(value=>{
return value
})
console.log(message)
}2.Demande étape par étape
var message = new Promise((resolve,reject)=>{
//Demande de validation avant demande formelle
setTimeout(function(){
resolve('success')
},3000)
}).then(value=>{
if(value=='success'){//Authentification réussie
return new Promise((resolve,reject)=>{
setTimeout(function(){
resolve({username:'xx'})
},3000)
})
}
})
message.then(res=>{
console.log(res.username)
})边栏推荐
- 问题3 — messageBox弹框,修改默认背景色
- C# Lambda
- OpenCV get(propId) 常用的值
- dhcp、tftp基础
- Synthesize video through ffmpeg according to m3u8 file of video on the network
- Interview tutorial - multi thread knowledge sorting
- Small sample fault diagnosis - attention mechanism code - Implementation of bigru code parsing
- "Adobe international certification" about Adobe Photoshop, creating and modifying brush tutorials?
- How to design a highly available and extended image storage function
- 自动化测试的未来趋势
猜你喜欢
随机推荐
2021-03-16 COMP9021第九节课笔记
11--无重复字符的最长子串
基金的募集,交易与登记
App Startup
Solve the problem of notebook keyboard disabling failure
MAYA重新拓布
11-- longest substring without repeated characters
Paper notes: multi label learning dm2l
C语言_字符串与指针的爱恨情仇
你还只知道测试金字塔?
蓝桥杯_N 皇后问题
一文带你了解Windows操作系统安全,保护自己的电脑不受侵害
Analysis of abnormal problems in domain name resolution in kubernetes
2022年制冷与空调设备运行操作上岗证题库及模拟考试
OpenCV get(propId) 常用的值
Installation and use of selenium IDE
Nodejs redlock notes
Opening chapter of online document technology - rich text editor
3D数学基础[十七] 平方反比定理
You get in Anaconda




![3D数学基础[十七] 平方反比定理](/img/59/bef931d96883288766fc94e38e0ace.png)




