axios 默认是 Payload 格式数据请求,但有时候后端接收参数要求必须是 Form Data 格式的,所以我们就得进行转换
//把数据的键值对放在form对象里面
const form = new FormData()
form.append('index', 1)
form.append('pageSize', 10)
form.append('categoryId', 0)
const t = this;
//照常发axios请求,数据就是form
axios.post('http://localhost:7777/article/articleLists',form)
.then(function (response) {
console.log(response);
t.articleList=response.data.data;
})
.catch(function (error) {
console.log(error);
});