axios 提交formData和json
引入qs
import qs from 'qs'
axios 提交formData
method: 'POST', data: {}, headers: { "Content-Type": "application/x-www-form-urlencoded", }, transformRequest: [ params => { // console.log('paramsSerializer', params) return qs.stringify(params, { arrayFormat: 'repeat' }) } ]
提交json
method: 'POST', data: JSON.stringify(params), headers: { 'Content-Type': 'application/json' }, transformRequest: null