当前位置:网站首页>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>
边栏推荐
- 关于安全帽识别系统,你需要知道的选择要点
- Node-3.构建Web应用(二)
- 基于AI智能图像识别:4个不同的行业应用
- pip安装报错:is not a supported wheel on this platform
- 梅科尔工作室-PR第三次培训笔记(效果与转场及插件使用)
- 从概念认识AI
- Joint 3D Instance Segmentation and Object Detection for Autonomous Driving
- 如何快速转行做产品经理
- The selection points you need to know about the helmet identification system
- 安全帽识别系统-为安全生产保驾护航
猜你喜欢
Node-2.垃圾回收机制
CNN-based Point Cloud De-Noising
Mei cole studios - sixth DjangoWeb application framework + MySQL database training
关于安全帽识别系统,你需要知道的选择要点
梅科尔工作室-HarmonyOS应用开发的第二次培训
STM32F407-浅~~析UART异步通信&USART_Init函数入口参数
Waymo dataset usage introduction (waymo-open-dataset)
Reconstruction and Synthesis of Lidar Point Clouds of Spray
产品如何拟定优化方案?
关于mmdetection框架实用小工具说明
随机推荐
蓝牙技术-简介
Asp doNet Mvc4绑定js脚本用法
Mei cole studios - fifth training DjangoWeb application framework + MySQL database
梅科尔工作室-DjangoWeb 应用框架+MySQL数据库第三次培训
微文案也能提升用户体验
STM32 基于固件库的工程模板的建立
产品版本号是如何确定的
防盗链——防止其他页面通过url直接访问本站资源
Hard hat recognition algorithm
梅科尔工作室-DjangoWeb 应用框架+MySQL数据库第五次培训
基于AI智能图像识别:4个不同的行业应用
自定义形状seekbar学习
STM32F407-浅~~析UART异步通信&USART_Init函数入口参数
Diagnostic Log and Trace——DLT 离线日志存储
解决jupyter中import torch出错问题
支付牌照是什么意思
Reconstruction and Synthesis of Lidar Point Clouds of Spray
Maykel Studio - Django Web Application Framework + MySQL Database Third Training
梅科尔工作室-Pr第一次培训笔记(安装及项目创建)
Node-2.垃圾回收机制