怎样让下面这段代码变成同步,顺序的打印出1 0 0 0 2 0 0 0 3 0 0 0 4 5
func() {
console.log(1)
const arr = [2, 3, 4]
arr.forEach((num, idx) => {
this.$http.get('a-url').then(() => {
const interval = setInterval(() => {
let i = 0
this.$http.get('b-url').then(() => {
i = i + 1
console.log(0)
if(i === 3) {
clearInterval(interval)
}
})
}, 1000)
})
console.log(num)
})
console.log(5)
}