添加功能的实现
1:首先绑定表单以便获取数据
2:调用添加数据接口
3:如果添加成功 ,就触发自定义的关闭按钮然后关闭弹窗
4:打印提交失败,结束函数
handleSubmit(){
this.$refs.userForm.validate(async(valid)=>{
if(valid){
let res = await this.$http.post("/api/user/add",{
...this.user
})
console.log(res)
if(res.data.code===1){
//添加成功
this.$emit("close","success")
this.dialogFormVisible = false
}
}else{
console.log("error submit");
return false;
}
})
this.dialogFormVisible = false
},