function pri (num) {
return new Promise((resolve,reject) => {
console.log('开始'+num)
resolve(num)
})
}
const list = [1,2,3]
function done(list,cb){
list.reduce((s,v) => {
return s.then(res => {
console.log(res)
if (res) {
return cb(v+res)
}else{
return cb(v)
}
})
},Promise.resolve())
}
done(list,pri)
let p = Promise.resolve()
for (const i of list) {
p = p.then(() => pri(i))
}