使用方法:
1.安装qs
npm install qs
2. 设置content-type为application/x-www-form-urlencoded
const instance = axios.create({
url: url,
method: method,
withCredentials: true,
headers: {
'content-type':'application/x-www-form-urlencoded'
}
})
3.PUT使用
if(method==='PUT') {
return new Promise((resolve, reject) => {
const config = {
url: url,
data: Qs.stringify(params),
method: method
} as AxiosRequestConfig
instance(config).then(resp => {
resolve(resp)
}).catch(error => {
reject(error)
})
})
}