axios 异步定义方法
//示例一:同步 async changeMailFlag(data) { try { const res = await saveOverSeasMailFlag({ mailFlag: data.data.mailFlag, groupId: data.data.groupId }); if (res.code == 0) { this.$message.success('保存邮寄状态成功'); this.queryOverseasInfoList(); } else throw new Error(res.msg); } catch (e) { this.$message.error(`保存邮寄状态失败,${e.message}`); } }
// 示例二:异步then进行回调
saveMoveIn() { let req = { ...this.entryInfo }; saveMoveIn(req) .then(res => { if (res.code == 0) { this.$message.success('添加成功'); // this.getMoveInList(); return; } else { this.$message.error(res.msg); } }) .then(() => { this.getMoveInList(); }); },