循环foreach异步请求
报错代码:
async function delComponent() {
slots.title.forEach((item) => {
await store.dispatch('delComponent', item.id)
})
}
delComponent()
正确写法:
function delComponent() {
slots.title.forEach(async (item) => { //加在这里
await store.dispatch('delComponent', item.id)
})
}
delComponent()