.then写法:
const callOn = () => {
login({ mobile: data.telNumber, code: data.verificationCode })
.then(res => {
console.log(res)
})
.catch(err => {
console.log(err)
})
}
async await写法:
const callTest = async () => {
try {
const res = await login({ mobile: data.telNumber, code: data.verificationCode })
if (res.value) {
//登录成功的逻辑
return
}
//失败的逻辑
console.log(res.msg)
} catch (err) {
console.log(err)
}
}
有什么错误请指正,或者有什么更好的建议