前端知识,vue,网络应用和axios初始
<input type="button" value="get请求" class="get"><input type="button" value="post请求" class="post"><script src="https://unpkg.com/axios/dist/axios.min.js"></script><script>d
·
<input type="button" value="get请求" class="get">
<input type="button" value="post请求" class="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=4").then(function (response) {
console.log(response);
}).catch(function (error) {
console.log(error);
});
}
document.getElementsByClassName("post").item(0).onclick=function () {
axios.post("https://autumnfish.cn/api/user/reg",{username:"小南"}).then(function (response) {
console.log(response)
}).catch(function (err) {
console.log(err);
})
}
</script>
get请求效果图


更多推荐



所有评论(0)