0
我想在下面的代码中使用async/await。JS调用嵌套的异步函数
在if/else
部分,它验证正确,但嵌套函数不会被调用。
该代码仅在if/else
完成后停止。
难道有人会对此发光吗?谢谢。异步功能
if (q1.value === 'yes') {
await askQuestion()
} else {
await endConvo()
}
因为askQuestion()和endConvo()是异步的功能,在程序退出之前
async function initBot() {
await botui.message.bot({
content: `Do you have any questions?`
})
let q1 = await botui.action.button({
action: [{
text: 'Yes',
value: 'yes'
}, {
text: 'No',
value: 'no'
}]
})
// This is where it's stuck
if (q1.value === 'yes') {
askQuestion()
} else {
endConvo()
}
let endConvo = async() => {
await botui.message.bot({
content: `END`
})
}
let askQuestion = async() => {
await botui.message.bot({
content: `What's your questions?`
})
}
}
export default initBot
对我不起作用 – shawnl
函数未被调用? – marvel308