methods: { handleAdd (arr) { this.loading = true const allApi = [] arr.forEach((item, index) => { const data = { id: item.id, name: item.name } const oneApi = api.add(data).then(res => { if (res.error_code === 0) { this.$message.success(res.msg) } else { this.$message.error(res.msg) } }) allApi.push(oneApi) }) Promise.all(allApi).then(() => { this.loading = false }) } }
原文链接:https://blog.csdn.net/m0_46251434/article/details/114324020
标签:arr,vue,const,res,allApi,接口,item,promise From: https://www.cnblogs.com/lylweb/p/16612233.html