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