Vue如何使用Post进行表单提交(post,vue,开发技术)

时间:2024-05-04 07:05:28 作者 : 石家庄SEO 分类 : 开发技术
  • TAG :

使用Post进行表单提交

下面就是使用Vue提交表单的方法

Vue如何使用Post进行表单提交

submitForm(event){ event.preventDefault(); letformData=newFormData(); formData.append('id',this.param.id); formData.append('categoryName',this.param.namee); formData.append('description',this.param.descrip); varurl=""; if(this.isSave){ url="http://localhost:8080/bookStore/category.do?flag=add" }else{ url="http://localhost:8080/bookStore/category.do?flag=update&id="+this.param.id } this.$http.post(url,formData).then(function(res){ if(res.status===200){ this.isShowModal=false; vartitle=this.isSave?"添加成功!":"修改成功!"; swal({title:title,text:"",type:"success"}); this.queryData(); this.clearData(); } }) }

vue中使用Post问题

get的使用

this.$axios.get("/api/Main/InputValue",{params:{//传参json:"123"}}).then(function(res){//console.log(res)}).catch(function(err){console.log("请求失败233");});

post的使用

this.$axios.post("/api/Main/posttest",{json:"123"})//传参.then(function(res){console.log(res)}).catch(function(err){console.log("请求失败233");});

post和get传参数的方式是不一样的,写post的时候如果在params里面传参数,后台是收不到的

 </div> <div class="zixun-tj-product adv-bottom"></div> </div> </div> <div class="prve-next-news">
本文:Vue如何使用Post进行表单提交的详细内容,希望对您有所帮助,信息来源于网络。
上一篇:windows系统下安装Cypress及cypress open报错怎么解决下一篇:

20 人围观 / 0 条评论 ↓快速评论↓

(必须)

(必须,保密)

阿狸1 阿狸2 阿狸3 阿狸4 阿狸5 阿狸6 阿狸7 阿狸8 阿狸9 阿狸10 阿狸11 阿狸12 阿狸13 阿狸14 阿狸15 阿狸16 阿狸17 阿狸18