现在我写了一个vue,使用了api的方法,想要发送数据给后台,那我应该如何写这个方法呢,使得后台能接收到这个json
//调用的方法
import { changePassword } from "@/api/user";
//api里面的方法
// @Summary 修改密码
// @Produce application/json
// @Param data body {username:"string",password:"string",newPassword:"string"}
// @Router /user/changePassword [post]
export const changePassword = (data) => {
return service({
url: "/user/changePassword",
method: 'post',
data: data
})
}
//表单数据
ruleForm: {
id: '',
oldpass: '',
pass: '',
checkPass: ''
},
//需要重写的方法
methods: {
submitForm(){
let data = this.ruleForm;
changePassword(data);
},
//服务器里的映射
// Modify password structure
type ChangePasswordStruct struct {
Username string `json:"id"`
Password string `json:"oldpass"`
NewPassword string `json:"checkPass"`
}