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("用户名或者密码不对");
                     }
                    }); 
        }
发布了59 篇原创文章 · 获赞 11 · 访问量 1万+

猜你喜欢

转载自blog.csdn.net/qq_41160739/article/details/104705959
今日推荐