我需要使用vue http get传递数组。但我不确定该怎么做,我知道我可以使用(我正在使用spatie/laravel-query-builder) '/users?filtername=John‘传递get方法的参数。
我有一个类别= 10,20,100的数组;类别的容器是id。我需要把id传给拉威尔控制员。
要调用get的vue.js
axios.get(url).then((res) => {
console.log(res.data);
})
.catch((err) => console.error(err));发布于 2019-02-19 17:23:32
您需要获取传递的数据,并将此字符串分配给一个JSON.stringify参数(在本例中为:myArray)。
const data = [{ id: 1 }, { id: 2 }]
const url = 'https://myendpoint.com'
axios.get(url, {
params: {
myArray: JSON.stringify(data)
}
}).then(res => console.log(res))https://stackoverflow.com/questions/54758334
复制相似问题