const params = new URLSearchParams();//前端在傳參時需要先新建一個URLSearchParams對象,然后將參數append到這個對象中 params.append('data',JSON.stringify(this.addPlanRoute))//幾個參數就append幾次,對應格式append('參數名',參數值) params.append('year',2019) axios({ method:"post", url:"http://localhost:8080/ceshi", headers: {"Content-Type": "application/x-www-form-urlencoded; charset=UTF-8" },//設置提交表頭'application/x-www-form-urlencoded; charset=UTF-8'數據格式
withCredentials:true,
data: params //將params對象傳遞到接口參數
}).then((res)=>{ console.log(res); });//打印返回結果
