axios中get与post方式传参区别

axios中get与post方式传参区别
强烈推介IDEA2020.2破解激活,IntelliJ IDEA 注册码,2020.2 IDEA 激活码
  • get用params
let params ={startTime:startTime,endTime: endTime} 
axios({
          url: url,
          headers: {
            'Content-Type': 'application/json; charset=UTF-8',
            'Access-Control-Allow-Origin': '*'
          },
          withCredentials:false,//跨域问题
          credentials: 'same-origin',
          method: 'get',
          timeout: 1000 * 10,//10秒
          params: params
        }).then(function(response) {
            //处理响应结果
        })
})
  • post用data
let data ={startTime:startTime,endTime: endTime} 
axios({
          url: url,
          headers: {
            'Content-Type': 'application/json; charset=UTF-8',
            'Access-Control-Allow-Origin': '*'
          },
          withCredentials:false,//跨域问题
          credentials: 'same-origin',
          method: 'get',
          timeout: 1000 * 10,//10秒
          data : data 
        }).then(function(response) {
            //处理响应结果
        })
})

 

本文来源huayang183,由架构君转载发布,观点不代表Java架构师必看的立场,转载请标明来源出处:https://javajgs.com/archives/18651

发表评论