// 登录
login_btn() {
if (this.pass == "" || this.user == "") {
alert("输入框不能为空")
}
console.log(this.user)
axios.post('/login/', {
username: this.user,
password: this.pass,
},{headers:{'Content-Type':'application/x-www-form-urlencoded'}})
// 返回数据
.then(response => {
alert("登录成功")
})
// 错误信息
.catch(error => {
alert("登录失败,请检查账号/密码是否正确")
});
},
PS:一定在提交的时候请求头加上这个,否则会一直403
原因:不加的话是Request Payload类型,而不是form-data