common.js:
common函數(shù)傳遞的參數(shù)添加?contentType:?'application/x-www-form-urlencoded'?即可改變post請(qǐng)求參數(shù)傳遞的格式
import axios from 'axios'
import qs from 'qs'
const service = axios.create()
export const common = async (config) => {
if (config.contentType === 'application/x-www-form-urlencoded') {
config.headers = { 'content-type': 'application/x-www-form-urlencoded' }
config.data = qs.stringify(config.data)
}
let res = await service(config)
return res
}
?
?
?
?
?
本文摘自 :https://blog.51cto.com/x