解决办法:加上{ "Content-Type":"application/json"}
login() {
this.$http
.post("URL",{
"username":this.username,"password":this.password
},{
"Content-Type":"application/json"},{
emulateJSON:true
})
.then(function(result) {
console.log(result);
if(result.data.code == 1)
{
alert("登录成功");
window.location.href = "index.html";
}else{
alert("用户名或者密码不对");
}
});
}