get请求:
1 on_sum: function () { 2 axios.get('http://127.0.0.1:8000/test/' 3 ).then(response=>{ 4 alert('ok') 5 }).catch(error=>{ 6 alert(error) 7 }) 8 }
post请求
1 on_sum: function () { 2 axios.post('http://127.0.0.1:8000/test/', 3 {'key':'value' 4 ...... 5 }).then(response=>{ 6 7 }).catch(error=>{ 8 9 }) 10 }
axios API
on_sum: function (){
axios({
method:'post',
url:'/test/',
data:{
firstName: 'Fred',
lastName: 'Flintstone'
}
}).then(response=>{
pass
}).error(error=>{
pass
})
},
请求方法的别名
为方便起见,为所有支持的请求方法提供了别名