亚洲乱码中文字幕综合,中国熟女仑乱hd,亚洲精品乱拍国产一区二区三区,一本大道卡一卡二卡三乱码全集资源,又粗又黄又硬又爽的免费视频

axios?POST提交數(shù)據(jù)的三種請(qǐng)求方式寫(xiě)法示例

 更新時(shí)間:2023年09月01日 09:27:54   作者:Awbeci  
這篇文章主要介紹了axios?POST提交數(shù)據(jù)的三種請(qǐng)求方式寫(xiě)法示例,有需要的朋友可以借鑒參考下,希望能夠有所幫助,祝大家多多進(jìn)步,早日升職加薪

1、Content-Type: application/json

import axios from 'axios'
let data = {"code":"1234","name":"yyyy"};
axios.post(`${this.$url}/test/testRequest`,data)
.then(res=>{
    console.log('res=>',res);            
})

2、Content-Type: multipart/form-data

import axios from 'axios'
let data = new FormData();
data.append('code','1234');
data.append('name','yyyy');
axios.post(`${this.$url}/test/testRequest`,data)
.then(res=>{
    console.log('res=>',res);            
})

3、Content-Type: application/x-www-form-urlencoded

import axios from 'axios'
import qs from 'Qs'
let data = {"code":"1234","name":"yyyy"};
axios.post(`${this.$url}/test/testRequest`,qs.stringify({
    data
}))
.then(res=>{
    console.log('res=>',res);            
})

總結(jié)

1、從jquery轉(zhuǎn)到axios最難忘的就是要設(shè)置Content-Type,還好現(xiàn)在都搞懂了他們的原理

2、上面三種方式會(huì)對(duì)應(yīng)后臺(tái)的請(qǐng)求方式,這個(gè)也要注意,比如java的@RequestBody,HttpSevletRequest等等

以上就是axios POST提交數(shù)據(jù)的三種請(qǐng)求方式寫(xiě)法示例的詳細(xì)內(nèi)容,更多關(guān)于axios POST提交數(shù)據(jù)請(qǐng)求方式的資料請(qǐng)關(guān)注腳本之家其它相關(guān)文章!

相關(guān)文章

最新評(píng)論