axios.get(url, 配置项).then().catch()
example:
axios.get(`URL`,{ params: { //get请求携带参数 a: 1, b: 2 } }).then( res => { console.log( res ) }).catch( error => console.log( error ))
axios.defaults.headers.post[‘Content-Type‘] = ‘application/x-www-form-urlencoded‘;
axios.post(url,配置).then().catch()
example:
axios.post(`URL`,{ username: ‘张三‘, password: ‘123‘ }).then( res => { console.log( res ) }).catch( err => console.log( err ))
原文:https://www.cnblogs.com/zengfanjie/p/11721366.html