Vue.js
本章內容:
#### axios axios
是一個基於Promise 用於瀏覽器和 nodejs 的 HTTP 客戶端,本質上也是對原生XHR的封裝,只不過它是Promise的實現版本,符合最新的ES規範 。
示例語法
// 合用,既可以發get請求,又可以發post請求
axios({
url: "請求地址",
method: "get",
data: { // 參數
name: "",
age: ""
}
}).then((res) => {}).catch((err) => {})
// get語法
axios.get("請求地址",{
// 參數
params: {
name: "",
age: ""
}
}).then((res) => {}).cathch((err) => {})
// post語法
axios.post("請求地址",{
// 參數
name: "",
age: ""
}).then((res) => {}).catch((err) => {})