恶补一下关于axios的知识
1、axios本身可以做到这些

2、与谁联合使用
一般情况下都与vue联合使用,也就是SpringBoot+Vue+axios+json+Element-UI
3、如何在项目中引入axios
import axios from 'axios'
4、如何使用axios执行get和post请求
get请求(获取到参数的两种方法):
//方法一
axios.get('/user?ID=12345')
.then(function(resp)=>{
      console.log(resp.data);
}
.catch(function(error){
      console.log(error);
});
//方法二
axios.get('/user',{
params:{
      ID:12345
}
}).then(function(resp)=>{
      console.log(resp.data);
}).catch(function(error){
      console.log(error);
});
post请求(传递参数的方法):
axios.post('/user',{
      firstName:'ZiJin',
      lastName:'Liu'
}).then(function(response)=>{
      console.log(response);
}).catch(function(error){
      console.log(error);
});
//还可以这样
axios({
      method:'post',
      url:'/user/12345',
      data:{
      firstName:'ZiJin',
      lastName:'Liu'
}
});
始终坚信———写一遍就能记住这个真理!
 
                    
                
 
                
            
         
         浙公网安备 33010602011771号
浙公网安备 33010602011771号