vue 使用 application/x-www-form-urlencoded格式提交數據


  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); });//打印返回結果

 


免責聲明!

本站轉載的文章為個人學習借鑒使用,本站對版權不負任何法律責任。如果侵犯了您的隱私權益,請聯系本站郵箱yoyou2525@163.com刪除。



 
粵ICP備18138465號   © 2018-2025 CODEPRJ.COM