React 中报错:Unexpected reserved word ‘await‘
React 中报错:Unexpected reserved word 'await' ,可以看到的是,在函数定义的时候加上async 这个关键字就不会报错了
·
这个是因为在函数定义的时候没有使用关键字 async
错误代码:
userLoginOut=()=> {
let result = await Dialog.confirm({
content: '人在天边月上明',
})
if (result) {
Toast.show({ content: '点击了确认', position: 'bottom' })
} else {
Toast.show({ content: '点击了取消', position: 'bottom' })
}
}
解决问题之后:
userLoginOut=async()=> {
let result = await Dialog.confirm({
content: '人在天边月上明',
})
if (result) {
Toast.show({ content: '点击了确认', position: 'bottom' })
} else {
Toast.show({ content: '点击了取消', position: 'bottom' })
}
}
可以看到的是,在函数定义的时候加上async 这个关键字就不会报错了
希望对你有所帮助!
更多推荐


所有评论(0)