如何将对象转换为location%5Bokrug%5D%5B%5D=38&location%5Bokrug%5D%5B%5D=41
:
let filter = {
location: {
okrug: [38, 41]
}
}
URLSearchParams
没有帮助:
console.log(new URLSearchParams(filter).toString()) //got location=%5Bobject+Object%5D
location%5Bokrug%5D%5B%5D=38&location%5Bokrug%5D%5B%5D=41
1条答案
按热度按时间eqqqjvef1#
您可以使用像qs这样经过全面测试的查询解析器库。
我在下面提供了一个使用6.11.0版本的代码片段。
第一个
输出
location%5Bokrug%5D%5B0%5D=38&location%5Bokrug%5D%5B1%5D=41
相关问题