<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>
本文地址:https://blog.csdn.net/qq_44772414/article/details/107476882
如对本文有疑问, 点击进行留言回复!!
2020-07-21 html5如何监听veido的全屏 + css的字体间距 + JS的window.open() + 软技能svn与git
html+css+js适合前端小白的实战全解(超详细)——2048小游戏(二)
在使用@angular/cli创建的angular项目上添加postcss等一系列移动端自适应插件
网友评论