1、安装Qs依赖
npm install qs
2、js中引用Qs
import Qs from 'qs'
3、构造数据
var formData = Qs.stringify({
username:'test',
password:'123456'
});
4、使用数据
axios.request({
url: '/auth/login',
method: 'POST',
data: formData,
headers: {
'Content-Type': 'application/x-www-form-urlencoded; charset=UTF-8',
'Authorization': 'Bearer ' + token
}
})