代码
async fun() {
try{
const res = await axios.get(url)
if(res.status===200 && res.data.code===0){
console.log(res)
//操作数据
}else{
//数据获取失败
}
}catch(error){
//捕获异常
console.log(error)
}
},
案例
async handleUnlockResume() {
try {
const res = await unlockResumes(this.selectedRowKeys);
if (res.status === 200) {
if (res.data.code === 0) {
this.$message.success("解锁简历成功", 2);
this.fetchResumes();
} else {
this.$message.error(
res.data.mesg ? res.data.mesg : "解锁简历失败",
2
);
}
}
} catch (error) {}
},