methods:{
myclick(){
this.$http({
methods:"post",
url:"../../../static/my.json",
headers:{"Content-Type":'application/x-www-form-urlencoded; charset=UTF-8'}
}).then((res)=>{
console.log(JSON.stringify(res.data).length);
if(JSON.stringify(res.data).length>0){
this.myshow=false;
}else{
this.myshow=true;
}
})
}
}
myclick(){
this.$http({
methods:"post",
url:"../../../static/my.json",
headers:{"Content-Type":'application/x-www-form-urlencoded; charset=UTF-8'}
}).then((res)=>{
console.log(JSON.stringify(res.data).length);
if(JSON.stringify(res.data).length>0){
this.myshow=false;
}else{
this.myshow=true;
}
})
}
}
本文介绍了一种在Vue项目中使用$http方法发起POST请求的具体实现方式,并展示了如何通过判断响应数据长度来控制组件状态的变化。
3885

被折叠的 条评论
为什么被折叠?



