報(bào)錯(cuò):Unexpected reserved word 'await'?
async和await是成對(duì)出現(xiàn)的。會(huì)報(bào)上邊的錯(cuò)是因?yàn)闆]有把a(bǔ)sync放在和await最近的函數(shù)上。
舉例:
報(bào)錯(cuò)代碼:
1 async confirmAll() { 2 this.$refs['editeForm'].validate((valid) => { 3 if (valid) { 4 const { success } = await retrievePassword(this.formline) 5 if (success) { 6 this.$message.success('操作成功!') 7 } 8 } 9 }) 10 }
修改后:
1 confirmAll() { 2 this.$refs['editeForm'].validate(async(valid) => { 3 if (valid) { 4 const { success } = await retrievePassword(this.formline) 5 if (success) { 6 this.$message.success('操作成功!') 7 } 8 } 9 }) 10 }

浙公網(wǎng)安備 33010602011771號(hào)