axios中get与post方式传参区别
程序员文章站
2022-04-15 12:40:51
...
- get用params
let params ={startTime:startTime,endTime: endTime}
axios({
url: url,
headers: {
'Content-Type': 'application/json; charset=UTF-8',
'Access-Control-Allow-Origin': '*'
},
withCredentials:false,//跨域问题
credentials: 'same-origin',
method: 'get',
timeout: 1000 * 10,//10秒
params: params
}).then(function(response) {
//处理响应结果
})
})
- post用data
let data ={startTime:startTime,endTime: endTime}
axios({
url: url,
headers: {
'Content-Type': 'application/json; charset=UTF-8',
'Access-Control-Allow-Origin': '*'
},
withCredentials:false,//跨域问题
credentials: 'same-origin',
method: 'get',
timeout: 1000 * 10,//10秒
data : data
}).then(function(response) {
//处理响应结果
})
})