当前位置:网站首页>Promise usage
Promise usage
2022-07-22 20:02:00 【You must work hard, but don't worry】
When adding new employees First judge whether the mobile phone number is registered If registered You can't add If not registered You can add
// Verify whether the mobile phone number is registered
checkOilStaffMobilePhone() {
return new Promise((resolve, reject) => {
checkOilStaffMobilePhone({
mobilePhone: this.ruleForm.mobilePhone
}).then(res => {
resolve(res)
})
})
},
// New employees
createOilStaff(formName) {
this.$refs[formName].validate(valid => {
if (valid) {
this.checkOilStaffMobilePhone().then(res => {
if (res) {
createOilStaff(this.ruleForm).then(() => {
this.$message({
message: ' Saved successfully ', type: 'success' })
this.newAddStaffDialog = false
this.getStaffList()
})
} else {
this.$message.error(' This mobile number has been registered ')
}
})
}
})
},
C() {
Promise.all([ this.A(), this.B() ]).then(res => {
res Is an array A and B The return value of
}
})
},
A() {
return new Promise((resolve, reject) => {
rechargeOverviewInfo().then(data => {
resolve(data)
})
})
},
B() {
return new Promise((resolve, reject) => {
getRechargeCardInfoToday().then(data => {
resolve(data)
})
})
}
async
async a(){
await this.b()
}
b() {
return new Promise((resolve, reject) => {
setTimeout(() => {
resolve(' success ')
}, 1000)
})
}
边栏推荐
- Persistence of spark RDD (cache, checkpoints, broadcast variables, and accumulators)
- Dynamic memory management and flexible array
- As a beginner, I don't want to use eslint
- Data warehouse model design and tools
- var、let、const区别
- Unknown AVD name [Pixel_2_API_30], use -list-avds to see valid li
- From data standards to database design: solve the last mile problem of basic data standards (Part 2)
- 数组push时 覆盖的问题
- 登录页面的代码
- Flutter 2进阶(六):回调函数的使用
猜你喜欢
As a beginner, I don't want to use eslint
Spark RDD depends on the working principle of DAG
One master-slave replication of MySQL
From data standards to database design: solve the last mile problem of basic data standards (Part 1)
Typora下载和简单使用教程
开幕在即 | “万物互联,使能千行百业”2022开放原子全球开源峰会OpenAtom OpenHarmony分论坛
Vs Code common shortcut keys
JVM-jinfo的使用
jvm的jps简单使用
Spark RDD的依赖于DAG的工作原理
随机推荐
Spark:图(Graph)
NC54 三数之和
spinning
Xcode11 添加lanuchimage黑屏无法显示问题
* flutter 问题记录
Unknown AVD name [Pixel_2_API_30], use -list-avds to see valid li
nacos权限与数据库
appsstore transporter上传的时候一直卡在正在验证问题
NC4 判断链表中是否有环
微服务——Eruka
shell脚本
YPbPr 和 YCbCr的区别 .
【总结思考】高可用架构设计的7大核心原则
leetcode 394. 字符串解码
jvm-jhat(虚拟机堆转储快照分析工具)
NC27 集合的所有子集(一)
Summary of MySQL grant user permissions
Pure function and higher order function
jvm-jmap(内存映像工具)的使用
【校招总结】【旧文回顾】百度实习收获美团网易小米华为远景offer