get请求url拼接多个参数写法 您所在的位置:网站首页 webservice地址拼接参数 get请求url拼接多个参数写法

get请求url拼接多个参数写法

#get请求url拼接多个参数写法| 来源: 网络整理| 查看: 265

get请求的参数一般会自动解析到url后,但是在很多时候需要自己按照后端的规定拼接,比如遇到字符串数组属性的时候,需要把数组元素拆开。于是有如下办法:

export function deleteContents(contentIds, contentType, value) { return request({ url: `/system/ops/content/setoff?contentIds=${contentIds}&removeReason=${value}&contentType=${contentType}`, method: 'get', }) }

不直接传递params:query,而是把需要拼接的字段分开传入函数中,用$拼接 也可以写成箭头函数形式

export const deleteContents = (contentIds, contentType, value) => { return request({ url: `/system/ops/content/setoff、contentIds=${contentIds}&removeReason=${value}&contentType=${contentType}`, method: 'get', }) }

传入实参

deleteContents(contentIds, contentType, value);

最终接口请求效果: http://localhost/dev-api/system/ops/content/setoff?contentIds=WZ0d0cfced000d911ec8692fa163e64f6c2,WZ08e210720e86511eb8692fa163e64f6c2&removeReason=%E4%B8%8D%E8%A1%8C&contentType=1 在这里插入图片描述



【本文地址】

公司简介

联系我们

今日新闻

    推荐新闻

    专题文章
      CopyRight 2018-2019 实验室设备网 版权所有