热门
最新
红包
立Flag
投票
同城
我的
发布
保持热爱共赴山海
CSDN App 扫码分享
评论
3
打赏
- 复制链接
- 举报
下一条:
Vue p25 网络应用-axios的基本使用<head><meta charset="utf-8"><title>小黑记事本</title> <script src="https://unpkg.com/axios/dist/axios.min.js"></script> <script src="https://cdn.jsdelivr.net/npm/vue@undefined</script></head> <body> <input type="button" value="get请求" class="get"> <input type="button" value="post请求" class="post"> <script type="text/javascript"> document.querySelector(".get").onclick=function(){ axios.get("https//autumnfish.cn/api/joke/list?num=3") .then(function(response){ console.log(response); //成功时,参数是得到的响应 },function(err){ console.log(err);//失败时,err是异常信息 })} document.querySelector(".post").onclick=function(){ axios.post("https//autumnfish.cn/api/user/reg", {username:"西兰花"}) .then(function(response){ console.log(response); },function(err){ console.log(err); })} </script> </body>