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
1 on_sum: function () { 2 axios({ 3 methods:'post', 4 url:'/test/', 5 data:{ 6 firstName: 'Fred', 7 lastName: 'Flintstone' 8 }.then(response=>{ 9 pass 10 }).catch(error=>{ 11 pass 12 }) 13 }) 14 }
请求方法的别名
为方便起见,为所有支持的请求方法提供了别名