<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8">
<meta name="viewport" content="width=device-width, initial-scale=1.0">
<title>Document</title>
</head>
<body>
<!-- axios.get(地址?查询字符串).then(function(response){},function(err){} )
axios.post(地址,{key:value,key2:value2}).then(function(response){},function(err){}) -->
<!--key=value&key2=value2-->
<input type="button" value="get请求" class="get">
<input type="button" value="post请求" class="post">
<!--尝试用axios的get请求获取笑话,post请求登录-->
<script src="https://unpkg.com/axios/dist/axios.min.js"></script>
<script>
document.querySelector(".get").onclick = function(){
axios.get("https://autumnfish.cn/api/joke/list?num=3")
.then(function(response){
console.log(response);
},function(err){
coonsole.log(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>
</html>
完成后在网页控制台可以看见相关内容