axios前端向后端传值
axios向后端传值方式一:JSON.stringify()axios.post('/api/home/home',JSON.stringify({name:this.name,age:this.age}),{headers: {'Content-Type':'application/json'}})方式二:formDatalet formdata = new FormData
·
axios向后端传值
- 方式一:JSON.stringify()
axios.post('/api/home/home',JSON.stringify({
name:this.name,
age:this.age
}),{
headers: {
'Content-Type':'application/json'
}
})
- 方式二:formData
let formdata = new FormData
formdata.append("name",this.name)
formdata.append("age",this.age)
return axios.post('/api/hone/hone',formdata).then(res=>{
console.log(res)
}).catch(err=>{
console.log(err)
})
更多推荐
已为社区贡献2条内容
所有评论(0)