Vue使用Post进行表单提交

lxf2023-03-17 14:44:25
摘要

这篇文章主要介绍了Vue使用Post进行表单提交,具有很好的参考价值,希望对大家有所帮助。如有错误或未考虑完全的地方,望不吝赐教

目录
  • 使用Post进行表单提交
  • Vue中使用Post问题

使用Post进行表单提交

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

Vue使用Post进行表单提交

submitFORM(event) {
					event.preventDefault();
					let formData = new FormData();
					formData.append('id', this.param.id);
					formData.append('cateGoryName', this.param.namee);
					formData.append('description', this.param.descrip);
					var url ="";
					if(this.isSave){
						url = "Http://localhost:8080/bookStore/category.do?flag=add"
					}else{
						url = "http://localhost:8080/bookStore/category.do?flag=update&keylink">sshowModal=false;
						  var title = 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里面传参数,后台是收不到的~~~~ 

以上为个人经验,希望能给大家一个参考,也希望大家多多支持编程网。

前端开发

相关专题