在axios的URL中,使用'?”可以将参数添加到URL的末尾,使用'?&”可以在URL的末尾添加第一个参数。例如:
axios.get('/api/path?id=123') .then(function (response) { console.log(response); }) .catch(function (error) { console.log(error); })
axios.get('/api/path?id=123&name=hello') .then(function (response) { console.log(response); }) .catch(function (error) { console.log(error); })
在第一个例子中,参数'id”被添加到URL的末尾。而在第二个例子中,参数'id”和'name”都被添加到URL的末尾,使用'?&”在参数之间分隔。
上一篇:Axios重写了授权头部