我想实现任务1.2.3.4按顺序执行,但是目前程序是按1.3.4.2执行,请问有办法解决吗?
var do1=new Promise((resolve,reject)=>{console.log("任务1"), resolve()});
var do2=new Promise((resolve,reject)=>{setTimeout(() => {resolve(console.log("任务2"));}, 1000);});
var do3=new Promise((resolve,reject)=>{console.log("任务3"), resolve()});
var do4=new Promise((resolve,reject)=>{console.log("任务4"), resolve()});
var p = new Promise((resolve,reject)=>{resolve()});
p.then(do1)
.then(do2)
.then(do3)
.then(do4);