Vue.js 请求后台数据
var that = this;that.$http({//调用接口method:'POST',url:ctxPath + "/login/doLogin" ,params:{userName : acco
·
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包
更多推荐
已为社区贡献1条内容
所有评论(0)