网站首页 > 博客文章 正文
1、问题:
一个页面可能有多个并发请求,我们想在所有请求完成后做处理,promise.all很好解决这个问题。
2、示例
3、结果
示例代码
created () { this.$toast.loading({ duration: 0, forbidClick: true, loadingType: 'spinner' }) }, mounted () { this.init() }, methods: { init () { Promise.all([ this.$store.dispatch('getWeather', { city: '临沂', county: '兰山区' }), this.$store.dispatch('getWeather', { city: '临沂', county: '兰山区' }), new Promise((resolve, reject) => { setTimeout(() => { console.log(23456) resolve({}) }, 3000) }) ]).then(res => { this.$toast.clear() console.log(res) }) } }
猜你喜欢
- 2024-09-26 Vue3全新的前端构建工具vite学习(前端vue项目开发流程及架构)
- 2024-09-26 Vue核心知识:8.5如何在vuex中使用异步修改?推荐行为触发action
- 2024-09-26 Vue.nextTick 的工作机制(vue中nexttick原理)
- 2024-09-26 ES6(四)用Promise封装一下IndexedDB
- 2024-09-26 Vue项目处理错误上报如此简单(vue项目中遇到的问题,你是怎么解决)
- 2024-09-26 Vue开发:通过异步的方式加载vue组件
- 2024-09-26 Vue.js项目模板搭建(vue.js环境搭建)
- 2024-09-26 vue.js深入篇(一、响应式原理)(vue响应式源码解析)
- 2024-09-26 Vue中的nextTick方法是用来做什么的?
- 2024-09-26 Vue - 简单实现一个命令式弹窗组件
你 发表评论:
欢迎- 最近发表
-
- 给3D Slicer添加Python第三方插件库
- Python自动化——pytest常用插件详解
- Pycharm下安装MicroPython Tools插件(ESP32开发板)
- IntelliJ IDEA 2025.1.3 发布(idea 2020)
- IDEA+Continue插件+DeepSeek:开发者效率飙升的「三体组合」!
- Cursor:提升Python开发效率的必备IDE及插件安装指南
- 日本旅行时想借厕所、买香烟怎么办?便利商店里能解决大问题!
- 11天!日本史上最长黄金周来了!旅游万金句总结!
- 北川景子&DAIGO缘定1.11 召开记者会宣布结婚
- PIKO‘PPAP’ 洗脑歌登上美国告示牌
- 标签列表
-
- ifneq (61)
- messagesource (56)
- aspose.pdf破解版 (56)
- promise.race (63)
- 2019cad序列号和密钥激活码 (62)
- window.performance (66)
- qt删除文件夹 (72)
- mysqlcaching_sha2_password (64)
- ubuntu升级gcc (58)
- nacos启动失败 (64)
- ssh-add (70)
- jwt漏洞 (58)
- macos14下载 (58)
- yarnnode (62)
- abstractqueuedsynchronizer (64)
- source~/.bashrc没有那个文件或目录 (65)
- springboot整合activiti工作流 (70)
- jmeter插件下载 (61)
- 抓包分析 (60)
- idea创建mavenweb项目 (65)
- vue回到顶部 (57)
- qcombobox样式表 (68)
- vue数组concat (56)
- tomcatundertow (58)
- pastemac (61)
本文暂时没有评论,来添加一个吧(●'◡'●)