axios
- axios的作用
- axios 的使用
- get
- post
- axios()
axios的作用
ajax工具包
promie
支持請求和回應的攔截
nodejs和網頁端都可以使用
axios 的使用
安裝
npm install axios
匯入掛載
import axios from ‘axios’
Vue.prototype.@http=axios
在組件中使用
this.$http.get(url)
.then(res=>console.log(res))
.catch(err=>console.log(err))
get
get
get(url)
get(url?name=mumu&age=18)
get(url,{
params:
{
name:“mumu”,
age:18
}
})
post
post
post(url,data,config)
post(“http://www.mi.com/api/echo”,{name:“abc”,age:15})
post(“http://www.mi.com/api/echo”,“name=abc&age=15”,{
headers:{“Content-Type”:“application/x-www-form-urlencoded”}
})
axios()
axios()
url:xxxx 地址
method 方法 |post|get|put|delete|head
params get請求傳參
data
post、put請求傳參
headers 請求頭資訊
“Content-Type”
Content-Type:application/json
Content-Type: application/x-www-form-urlencoded;charset=utf-8
Content-Type:multipart/form-data
沒了…
轉載請註明出處,本文鏈接:https://www.uj5u.com/qita/4447.html
標籤:其他
上一篇:記錄Android 遷移到AndroidX時的步驟和注意事項
下一篇:axios的使用
