template el-button type=primary style=margin-left 16px click=drawer = true 添加管理员el-buttonel-drawer v-model=drawer title=I am the title with-header=false span click= drawer = falseXspanspan新增管理员span
根据提供的代码,有以下问题:
-
在
onSubmit函数中,formEl.validate后面应该是一个回调函数,而不是使用async声明一个异步函数。 -
在
onSubmit函数中,当数据验证通过后,应该使用await关键字等待管理员添加请求的结果,以便根据结果来关闭抽屉或者进行其他的操作。
修改后的 onSubmit 函数如下:
var onSubmit = (formEl) => {
formEl.validate((valid) => {
if (valid) {
service.admin.admin_add(form.value).then((res) => {
if (res.data.code == 200) {
console.log(111);
drawer.value = false; //关闭抽屉
} else {
console.log(222);
// ElNotification.closeAll();
// ElNotification.error({ message:'编辑管理员失败!' });
}
});
}
});
};
原文地址: https://www.cveoy.top/t/topic/bbKh 著作权归作者所有。请勿转载和采集!