前端传递数组给后端,多个相同key,对应不同值

一,若想传递数组,可以按照如下的拼接形式:

&materialsTypeId=11&materialsTypeId=12&materialsTypeId=&materialsTypeId=
特点:
同一个Key值可以出现多次
Value值可以为空

二,我的案例

在这里插入图片描述

三,我的处理方式

在这里插入图片描述
主要就是这个qs函数的转化数组。

headers: {
    
    'Content-Type': 'application/x-www-form-urlencoded; charset=UTF-8'},
transformRequest: [data => Qs.stringify(data, {
    
     indices: false })],

对应的qs使用:https://suwu150.blog.csdn.net/article/details/78333452

猜你喜欢

转载自blog.csdn.net/weixin_42349568/article/details/114978644