promise等待多个异步请求完毕后再执行其他代码的方法

 //这里等promise执行,避免拿不到图片临时路径
const promise1 = new Promise((resolve, reject) => {
		    uni.downloadFile({
		    	url:that.bg_img,
		    	success:(res)=>{ 	 
		    	 resolve(res)
		    	}
		    })
	});
	const promise2 = new Promise((resolve, reject) => {
		    uni.downloadFile({
		    	url:that.ewm,
		    	success:(res)=>{ 	 
		    	 resolve(res)
		    	}
		    })
	});
	Promise.all([promise1, promise2]).then((values) => {
	  // console.log(values);
	  this.make_canvas(values[0],values[1]);
	}); 
上一篇:axios post 回传数组至后台


下一篇:1762. Buildings With an Ocean View