Vue.js 请求后台数据

版权声明:本文为博主anzy原创文章,转载请注明地址 https://blog.csdn.net/qq_24549805/article/details/78838104
var that = this;
            that.$http({           //调用接口
                method:'GET',
                url:ctxPath + "/login/doLogin" , 
                params:{
                    userName : account.val().trim(),
                    password : passwd.val().trim()
                }
            }).then(function(response){  //接口返回数据
                if(response.body == "success"){
                    window.location.href = ctxPath + "/user/init";
                }else{
                    login.errorMsg=response.body;
                }
            },function(error){
            })


需要注意的是用HTTP请求时需要引入vue-resource.js


我就不多写了,网上例子比较多。可以多看看,我用的时候遇到的就是没引入vue-resource.js包




猜你喜欢

转载自blog.csdn.net/qq_24549805/article/details/78838104