get 方法1传入参数的时候,需要 { } 然后在里面传入 params 这个参数,一定要是params。
const id = 'xxx';const token = 'xxxxxxxxxxxxxxxxx';axios.get("http://xxx/xxx",{//参数列表params:{id :12345}, //请求头配置 headers:{ token: token}}).then((res)=>{console.log(res)}).catch((error)=>{console.log(error);})
post
const id = 'xxx';const token = 'xxxxxxxxxxxxxxxxx';axios.post("http://xxx/xxx",//参数列表{'id': id},//请求头配置 {headers: {'token':token }}).then((res)=>{console.log(res)})