1、找到添加用户按钮绑定一个点击事件让添加用户模态框显示出来
2、给模态框的确定按钮绑定一个点击事件
3、通过点击事件请求后台的添加用户接口。
4、后台服务器通过服务端语言实现接收浏览器请求
5、后端语言查询数据库
6、将结果返回给浏览器
7、通过js显示到页面上
8、隐藏掉添加用户的模态框
adduserlist() {
this.dialogFormVisible = false;
this.$refs.addue.validate(valid => {
if (valid) {
this.$axios({
method: "post",
url: "https://www.liulongbin.top:8888/api/private/v1/users",
data: {
username: this.form.username,
password: this.form.password,
email: this.form.email,
mobile: this.form.mobile
}
}).then(res => {
const {
meta: { re, status }
} = res.data;
if (status === 201) {
this.$message({
message: re,
type: "success"
});
} else {
this.$message({
message: re,
type: "error"
});
}
});
} else {
console.log("error submit!!");
return false;
}
});
},