我有了這個非常基本的異步等待,我認爲是不正確運行:基本異步的JavaScript等待
const ex = {
people:() => {console.log('people')},
places:() => {console.log('places')}
}
async function example() {
try {
const people = await ex.people()
const places = await ex.places()
} catch(err) {
console.log(err)
}
}
example().then(console.log('last'))
輸出:
people
last
places
應該不是這個被輸出「人,地,最後'?
你'people'和'places'函數不返回的承諾。那是故意的嗎? – gyre
感謝您的迴應,我曾嘗試過,但仍似乎沒有解決問題 – jj1111