Vue如何使用Post进行表单提交
导读:本文共1160字符,通常情况下阅读需要4分钟。同时您也可以点击右侧朗读,来听本文内容。按键盘←(左) →(右) 方向键可以翻页。
摘要: 使用Post进行表单提交下面就是使用Vue提交表单的方法submitForm(event){ event.preventDefault(); letformData=newFormData(); formData.append('id&... ...
音频解说
目录
(为您整理了一些要点),点击可以直达。使用Post进行表单提交
下面就是使用Vue提交表单的方法
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进行表单提交的详细内容,希望对您有所帮助,信息来源于网络。