returnaxios({method:'post',url:`目标地址`,data: temp,transformRequest:[function(data){let ret =''for(let it in data){
ret +=encodeURIComponent(it)+'='+encodeURIComponent(data[it])+'&'}return ret
}],headers:{'Content-Type':'application/x-www-form-urlencoded',}}).then(res=>{if(res && res.data && res.data.retCode){this.$message.success(res.data.retMsg)}}).catch(err=>{
console.log(err)});
get 请求
带参数请求
import axios from'axios'import qs from'query-string'exportfunctiongetRoles(data){returnaxios({method:'get',url:'',// 目标地址params: data
})}exportfunctiongetR(data){return axios.get('目标地址',qs.stringify(data))}