sunny123456

  博客园 :: 首页 :: 博问 :: 闪存 :: 新随笔 :: 联系 :: 订阅 订阅 :: 管理 ::
  1796 随笔 :: 22 文章 :: 24 评论 :: 226万 阅读
< 2025年3月 >
23 24 25 26 27 28 1
2 3 4 5 6 7 8
9 10 11 12 13 14 15
16 17 18 19 20 21 22
23 24 25 26 27 28 29
30 31 1 2 3 4 5

vue方法中的方法怎么同步顺序执行_vue方法同步(顺序)执行:async/await使用

项目中有一个地方需要获取到接口返回值之后根据返回值确定之后执行的步骤,使用async搭配await实现,await函数不能单独使用。方法如下:

async methodName(params){

let isSuccess = false;

await this.$http({

url: URL,

method: "get",

params: this.$http.adornParams({

params:params

})

}).then(({ data }) => {

if (data && data.code === 0) {

if(data.exist == 0){

isSuccess = true

}

}

}).catch(err => {

console.log(err);

this.$message({

type: "error",

message: "系统异常"

});

});

return isSuccess

}

https://blog.csdn.net/weixin_35044945/article/details/114009133
posted on   sunny123456  阅读(2485)  评论(0编辑  收藏  举报
相关博文:
阅读排行:
· DeepSeek 开源周回顾「GitHub 热点速览」
· 物流快递公司核心技术能力-地址解析分单基础技术分享
· .NET 10首个预览版发布:重大改进与新特性概览!
· AI与.NET技术实操系列(二):开始使用ML.NET
· .NET10 - 预览版1新功能体验(一)
历史上的今天:
2021-09-01 Microsoft Visio 2013 简体中文版
2021-09-01 visio2013产品密钥激活
2021-09-01 WebConfigurationManager和ConfigurationManager区别
2021-09-01 错误 the type "xxxx" is defined in an assembly that is not refernced.You must add a reference to assem
2021-09-01 Windows10安装oracle 19c数据库+PLsql详细安装过程
点击右上角即可分享
微信分享提示