生活随笔
收集整理的這篇文章主要介紹了
axios02-其他使用方式(推荐)
小編覺得挺不錯的,現在分享給大家,幫大家做個參考.
/*
1.學習目標介紹 : axios其他使用方式
2.學習路線 :(1)復習上一小節介紹的兩種方式axios.get().then()axios.post().then()(2)介紹第三種使用方式axios({url:'請求路徑',method:'請求方式',data:{ post請求參數 },params:{ get請求參數 }}).then(res=>{//成功回調//console.log(res)});
*/
<!DOCTYPE html>
<html lang="en"><head><meta charset="UTF-8"><meta name="viewport" content="width=device-width, initial-scale=1.0"><meta http-equiv="X-UA-Compatible" content="ie=edge"><title>Document
</title>
</head><body><button id="btn1">基本使用
</button><button id="btn2">點我發送get請求
</button><button id="btn3">點我發送post請求
</button><script src="./axios.js"></script><script>btn1.onclick = function () {axios({url: 'https://autumnfish.cn/api/joke',method: 'get',}).then(res => {console.log(res);})};btn2.onclick = function () {var num = 10;axios({url: `https://autumnfish.cn/api/joke/list?num=${num}`,method: 'get',}).then(res => {console.log(res);})};btn3.onclick = function () {axios({url: 'http://ttapi.research.itcast.cn/mp/v1_0/authorizations',method: 'post',data: {mobile: '18801185985',code: '246810'}}).then(res => {console.log(res);})};</script>
</body></html>
總結
以上是生活随笔為你收集整理的axios02-其他使用方式(推荐)的全部內容,希望文章能夠幫你解決所遇到的問題。
如果覺得生活随笔網站內容還不錯,歡迎將生活随笔推薦給好友。