当前位置:网站首页>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)
})边栏推荐
- List of Li Bai's 20 most classic poems
- Introduction to software engineering - Chapter 2 - feasibility study
- 487. 最大连续1的个数 II ●●
- 新准则金融资产三分类:AMC、FVOCI和FVTPL
- dhcp、tftp基础
- Easyplayerpro win configuration full screen mode can not be full screen why
- Écouter le réseau d'extension SWIFT (source)
- LabVIEW查找n个元素数组中的质数
- Getting started with ffmpeg
- 12--合并两个有序链表
猜你喜欢

FPGA的虚拟时钟如何使用?

2021-03-04 COMP9021第六节课笔记

2022 mobile crane driver special operation certificate examination question bank and online simulation examination

问题4 — DatePicker日期选择器,2个日期选择器(开始、结束日期)的禁用

Swift 基础 Swift才有的特性

2022年流动式起重机司机特种作业证考试题库及在线模拟考试

Coordinate transformation of graphic technology

Swift extension networkutil (network monitoring) (source code)

OC extension detects whether an app is installed on the mobile phone (source code)

For a detailed explanation of flex:1, flex:1
随机推荐
Swift 基础 闭包/Block的使用(源码)
2021-03-09 COMP9021第七节课笔记
貸款五級分類
Swift Extension NetworkUtil(網絡監聽)(源碼)
2022年制冷与空调设备运行操作上岗证题库及模拟考试
Tool functions – get all files in the project folder
io模型初探
13 -- 移除无效的括号
WCF TCP protocol transmission
Model effect optimization, try a variety of cross validation methods (system operation)
Detailed explanation of etcd backup and recovery principle and actual record of stepping on the pit
复习SGI STL二级空间配置器(内存池) | 笔记自用
2022茶艺师(中级)上岗证题库及在线模拟考试
1279_VMWare Player安装VMWare Tools时VSock安装失败解决
11-- longest substring without repeated characters
Methods of vector operation and coordinate transformation
Easyplayerpro win configuration full screen mode can not be full screen why
Analysis of abnormal problems in domain name resolution in kubernetes
Pipeline concept of graphic technology
问题3 — messageBox弹框,修改默认背景色