当前位置:网站首页>promise 改变状态的方法和promise 的then方法
promise 改变状态的方法和promise 的then方法
2022-08-11 05:25:00 【陈阳羽】
promise 改变状态的方法
<script>
/* promise 改变状态的方法 1.resolve() | pending==>fulfilled 2.reject()返回失败 | pending==>rejected 3.throw抛出错误 | pending==>rejected */
var p =new Promise((resolve,reject)=>{
reject()
})
console.log(p)
</script>
promise 的then方法
<script>
/* promise 的then方法 1.如果promise.then抛出错误 -则回调函数返回值状态为rejected 2.如果promise.then中return -非promise对象数据则返回值为数据值 3.如果promise.then中return新的promise -返回的状态 = 新的promise状态 -返回值 = 新的Promise的返回值 */
var p = new Promise((resolve, reject) => {
resolve('hi');
})
var th = p.then(res => {
// console.log(res)
// throw "cuole"
// return "hello"
return new Promise((resolve,reject)=>{
// resolve('success')
// reject("nope")
})
}, fild => {
console.log(fild)
})
console.log(th)
</script>
边栏推荐
- 跨应用间调用: URL Scheme
- 华为云IOT平台设备获取api调用笔记
- stm32-WS2812 PWM+DMA(自己写库函数)
- Mei cole studios - fifth training DjangoWeb application framework + MySQL database
- Node-3.构建Web应用(一)
- C语言的编译
- Maykel Studio - Django Web Application Framework + MySQL Database Fourth Training
- Hard hat identification
- 【调试记录1】提高MC3172浮点运算能力,IQmath库的获取与导入使用教程
- The kernel communicates with user space through character devices
猜你喜欢
Mei cole studios - deep learning second BP neural network
SWOT分析法
Diagnostic Log and Trace——dlt的编译和安装
梅科尔工作室-华为云ModelArts第一次培训
华为IOT设备消息上报和消息下发验证
STM32学习总结(一)——时钟RCC
目标检测——Faster R-CNN 之 Fast R-CNN
win10 配置tensorflow(GPU) anaconda3 cuda9.0 cudnn for 9.0
Maykle Studio - HarmonyOS Application Development First Training
自定义形状seekbar学习--方向盘view
随机推荐
梅科尔工作室-DjangoWeb 应用框架+MySQL数据库第五次培训
Toward a Unified Model
梅科尔工作室-HarmonyOS应用开发第三次培训
梅科尔工作室-DjangoWeb 应用框架+MySQL数据库第二次培训
目标检测——卷积神经网路基础知识
pip安装报错:is not a supported wheel on this platform
CMT2380F32模块开发3-GPIO例程
梅科尔工作室-第四次PR培训笔记(字幕和标题动画,关键帧动画和声音处理)
需求文档(PRD)撰写指南
Maykle Studio - HarmonyOS Application Development Fourth Training
stm32-WS2812 PWM+DMA(自己写库函数)
Use regex to verify whether the file name is legal
Node-3.构建Web应用(一)
The latest safety helmet wearing recognition system in 2022
Diagnostic Log and Trace——为应用程序和上下文设置日志级别的方法
咕咚vs悦跑圈的竞品分析
ActiveReports报表分类之页面报表
Safety helmet recognition system
CMT2380F32模块开发0-总览
The selection points you need to know about the helmet identification system