当前位置:网站首页>Promise中finally的用法
Promise中finally的用法
2022-07-01 03:08:00 【勇敢小陈】
Promise中除了常用的then和catch外,finally也是很重要的。
一、finally的作用
不管promise最后的状态,在执行完then或catch指定的回调函数以后,都会执行finally方法指定的回调函数。
二、应用场景
在项目中常遇到一些加载效果的功能,一般请求前页面显示加载效果,请求完成后取消页面加载效果,我一开始将标识放到then里面去处理,后面发现如果请求出错的情况下,页面一直加载没办法取消,后面将标识放到finally中去处理,从而解决了问题
equipmentApi
.adddingNode(data)
.then(({ code, message }) => {
if (code === 200) {
this.$message.success("新增成功!");
this.getTreeData();
this.handleCheck();
this.cancel();
} else if (code === 40001) {
} else {
this.$message.error(message);
}
})
.finally(() => {
this.buttonLoading = false;
});边栏推荐
- [applet project development -- Jingdong Mall] classified navigation area of uni app
- Latest interface automation interview questions
- 【小程序项目开发--京东商城】uni-app之自定义搜索组件(上)
- 【小程序项目开发-- 京东商城】uni-app之分类导航区域
- Mysql知识点
- Stop saying that you can't solve the "cross domain" problem
- STM32——一线协议之DS18B20温度采样
- Druid监控统计数据源
- VMware vSphere 6.7 virtualization cloud management 12. Vcsa6.7 update vCenter server license
- JUC learning
猜你喜欢

Saving images of different depths in opencv
![[exsi] transfer files between hosts](/img/c3/128b72aca6e030b2d4be2b6bddbc43.png)
[exsi] transfer files between hosts
![[linear DP] longest common subsequence](/img/47/c3172422e997009facbada929adb1a.jpg)
[linear DP] longest common subsequence

EtherCAT原理概述

【小程序项目开发-- 京东商城】uni-app之首页商品楼层

Restcloud ETL practice data row column conversion
![[small program project development -- Jingdong Mall] the home page commodity floor of uni app](/img/80/20bed20a6ab91e82ad6800b11f2caa.png)
[small program project development -- Jingdong Mall] the home page commodity floor of uni app

VMware vSphere 6.7虚拟化云管理之12、VCSA6.7更新vCenter Server许可

Network address translation (NAT) technology

Redis 教程
随机推荐
性能测试常见面试题
Chapter 03_ User and authority management
【小程序项目开发-- 京东商城】uni-app之分类导航区域
实战 ELK 优雅管理服务器日志
PTA 1017
Feign远程调用和Getaway网关
Basic concept and classification of sorting
Big orange crazy blog move notice
A few lines of transaction codes cost me 160000 yuan
如何校验两个文件内容是否相同
PHP batch Excel to word
Restcloud ETL data realizes incremental data synchronization through timestamp
Network address translation (NAT) technology
Analyze datahub, a new generation metadata platform of 4.7K star
The best learning method in the world: Feynman learning method
咱就是说 随便整几千个表情包为我所用一下
CX5120控制汇川IS620N伺服报错E15解决方案
POI导出excel,按照父子节点进行分级显示
Here comes the share creators budding talent training program!
# 使用 KubeKey 搭建 Kubernetes/KubeSphere 环境的'心路(累)历程'