目前最常用两种数据格式是以下两种
application/x-www-form-urlencoded
application/json
由于后台对请求数据要求不同,可能需要这两种数据格式。
1、当后台需要参数形式请求数据时,以下面这种形式
application/x-www-form-urlencoded
如下面请求例子
axios({
method:'post',
url:'http://114.213.212.41:8080/order/selectname',
data:'&time='+this.yuyueData[this.i]+'&m='+0,
})
.then(res=>{})
//或者
axios({
method:'post',
url:'http://114.213.212.41:8080/order/selectname',
data:qs.stringify({"time":this.yuyueData[this.i],"ampm":0
})
.then(res=>{})
2、当后台需要requestbody形式请求数据时,应以下面这种方式
application/json
如下面的例子
axios({
method:'post',
url:'http://114.213.212.41:8080/order/selectname',
data:{"time":this.yuyueData[this.i],"ampm":0}
})
.then(res=>{})