100字范文,内容丰富有趣,生活中的好帮手!
100字范文 > 在vue中使用axios发送post请求 参数方式

在vue中使用axios发送post请求 参数方式

时间:2021-10-28 02:53:30

相关推荐

在vue中使用axios发送post请求 参数方式

由于后台接收的参数格式为FormData格式,

在axios中参数格式默认为,

在传参数前,将原先官方提供的格式

改为如下:

axios({url: '../../../room/listRoomPage',method: 'post',data: {offset: 0, limit: 9999, roomCode: "", roomtypeId: 0, floorId: 0},transformRequest: [function (data) {var oMyForm = new FormData();oMyForm.append("offset", 0);oMyForm.append("limit", 9999);oMyForm.append("roomCode", "");oMyForm.append("roomtypeId", 0);oMyForm.append("floorId", 0);console.info(oMyForm);return oMyForm;}],headers: {'Content-Type': 'application/x-www-form-urlencoded'}}).then(function (response) {console.log(response);}).catch(function (error) {console.log(error);});

成功得到后台返回的数据

本内容不代表本网观点和政治立场,如有侵犯你的权益请联系我们处理。
网友评论
网友评论仅供其表达个人看法,并不表明网站立场。