国产成人毛片视频|星空传媒久草视频|欧美激情草久视频|久久久久女女|久操超碰在线播放|亚洲强奸一区二区|五月天丁香社区在线|色婷婷成人丁香网|午夜欧美6666|纯肉无码91视频

axios發(fā)送post請求帶參數(shù) axios發(fā)送post請求?

axios發(fā)送post請求?// post 數(shù)據(jù)let postData = { username: "user1", password: "123" }axios.post("/login", po

axios發(fā)送post請求?

// post 數(shù)據(jù)let postData = { username: "user1", password: "123" }axios.post("/login", postData) .then(response => { // post 成功,response.data 為返回的數(shù)據(jù) console.log(response.data) }) .catch(error => { // 請求失敗 console.log(error) })

怎么設(shè)置axios的全局請求參數(shù)?

vue.js 1.0 我們常使用 vue-resource (官方ajax庫), vue 2.0 發(fā)布后作者宣告不再對 vue-resource 進(jìn)行更新, 推薦我們使用 axios (基于 promise 的 http 請求客戶端,可同時(shí)在瀏覽器和 node.js 中使用)


安裝 axios


使用 npm

npm install axios

使用 yarn

yarn add axios

使用 axios


如同使用 vue-resource 一樣使用


main.js

import axios from "axios" vue.prototype.$http = axios

執(zhí)行 get 請求


this.$http.get("/user?id=12345") .then(function (response) { console.log(response) }) .catch(function (error) { console.log(error) })

以上就是本文的全部內(nèi)容,希望對大家的學(xué)習(xí)有所幫助,也希望大家多多支持腳本之家。