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)});
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
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))}