axios功能强大的网络请求库。
<script src="https://unpkg.com/axios/dist/axios.min.js"></script>
基础使用:
axios.get(地址?key=value&key2=values).then(function(response){},function(err){})
axios.get(地址,{key:value,key2:value2}).then(function(response){},function(err){})
<div id='app'>
<input type="button" value="get请求" @click="getdata">
<p>
{{joke}}
</p>
<input type="button" value="POST请求" @class="post">
</div>
<script>
var app =new Vue({
el:"#app",
data:{
joke:"数据",
},
methods: {
getdata:function(){
var that=this;
axios.get("https://v2.jinrishici.com/info").then(function(response) {
that.joke=response.data.beijingTime
},function(err){})
},
},
})
</script>
标签:function,axios,err,get,joke,第八课,vue,response From: https://www.cnblogs.com/superip/p/17292769.html