【发布时间】:2018-09-24 15:01:46
【问题描述】:
预期的查询字符串:
http://fqdn/page?categoryID=1&categoryID=2
axios 获取请求:
fetchNumbers () {
return axios.get(globalConfig.CATS_URL, {
params: {
...(this.category ? { categoryId: this.category } : {})
}
})
.then((resp) => {
// console.log(resp)
})
.catch((err) => {
console.log(err)
})
}
如您所见,1 个参数只需 1 个值即可完美运行,但如果我想创建多个值 - 它不起作用,我尝试使用数组:
...(this.category ? { categoryId: [1, 2] } : {})
但它以这种方式返回:
http://fqdn/page?categoryID[]=1&categoryID[]=2
所以它只是不起作用。看过这个问题:Passing an object with a parameter with multiple values as a query string in a GET using axios
但想不通,他是如何解决这个问题的。
【问题讨论】:
标签: javascript vue.js axios