当前位置:网站首页>Simple use of promise method
Simple use of promise method
2022-06-29 09:16:00 【swag_ Special actor】
es6 Of promise It's easy to use , Knowing the usage scenario is enough for daily use , Here are just a few notes , Record resolve and reject Use

effect :
there resolve,reject It literally means to go when you succeed resolve, Failure to walk reject; stay resolve,reject Adding data can be done in then From the callback function . We need to pay attention to then Take two functions , The first is to deal with resolve The second is reject Of
// promise Method
testPromise() {
var _Prom = new Promise(function(resolve, reject) {
var num = Math.ceil(Math.random() * 10) // Generate 1-10 The random number
if (num > 5) {
resolve(' Greater than 5 go resolve')
} else {
reject(' Less than 5 go reject')
}
})
return _Prom
},
test() {
this.testPromise().then(
res => {
console.log(res)
},
err => {
console.log(err)
}
)
}
边栏推荐
- Figure timers in SOC (I): what timers are there in the system?
- uni-app获取当前页面路由url
- Can we trust bounding box annotations for object detection
- train_ on_ Batch save the image of the loss function change
- verilog 归约操作符
- 宏,函数和内联函数
- 超融合架构和传统架构有什么区别?
- 记自定义微信小程序顶部导航栏
- ActiveMQ message component publish subscribe redelivery message redelivery
- 记微信小程序setData动态修改字段名
猜你喜欢

What is hyperfusion? What is the difference with traditional architecture

Verilog 大小端以及 +:使用

微信小程序分享页面,分享到朋友圈

ActiveMQ message component publish subscribe redelivery message redelivery

laravel 8 实现 订单表按月份水平分表

Scenario analysis of deadlock during MySQL insert

io流的总结

Summary of IO streams

Mysql使用union all统计多张表组合总数,并分别统计各表数量
![[to.Net] C data model, from Entity Framework core to LINQ](/img/98/6a8b295d1465697945e01b8c48ec52.png)
[to.Net] C data model, from Entity Framework core to LINQ
随机推荐
Open3d hidden point removal
工厂模式
Training view (issue temporary storage)
微信小程序子组件向页面传值(父子组件间的通信)带源码
MySQL virtual column
手写VirtualDOM
Training kernel switching using GPU
uni-app获取当前页面路由url
(transfer) mysql: error 1071 (42000): specified key was too long; max key length is 767 bytes
What is hyperfusion? What is the difference with traditional architecture
verilog 归约操作符
观察者模式怎么实现
在 RedisTemplate 中使用 scan
Multiplier design (pipeline) Verilog code
微信小程序项目:微信小程序页面布局
Verilog size and +: Using
网络安全问题
今天让你知道PMP考试通过率达97%,可信不可信
Mqtt second session -- emqx high availability cluster implementation
AugFPN:改进多尺度特征学习用于目标检测