vue http传值Bug: Post 415

解决办法:加上{ "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("用户名或者密码不对");
                     }
                    }); 
        }

 

posted @ 2020-03-06 22:25  neverthelessing  阅读(148)  评论(0)    收藏  举报