當(dāng)前位置:首頁 >  站長 >  編程技術(shù) >  正文

關(guān)于axios請求——delete方法

 2020-11-05 15:17  來源: 田珊珊個人博客   我來投稿 撤稿糾錯

  域名預(yù)訂/競價,好“米”不錯過

有的人只知道delete方法,傳值的時候,將請求值放在url上,而像post方法那些,帶有請求體,卻不知道該如果傳值。

首先,delete方法有三種寫法

一:請求參數(shù)拼接在url上

axios.delete('/delete', {

params: { // 請求參數(shù)拼接在url上

id: 12

}

}).then(res => {

console.log(res)

})

二:請求參數(shù)放在請求體

axios.delete('/delete', {

data: { // 請求參數(shù)放在請求體

id: 12

}

}).then(res => {

console.log(res)

})

三:請求參數(shù)拼接在url上或請求參數(shù)放在請求體

axios({

method: 'delete',

url: '/delete',

params: {}, // 請求參數(shù)拼接在url上

data: {} // 請求參數(shù)放在請求體

}).then(res => {

console.log(res)

})

文章來源:田珊珊個人博客

來源地址:http://www.tianshan277.com/796.html

申請創(chuàng)業(yè)報道,分享創(chuàng)業(yè)好點子。點擊此處,共同探討創(chuàng)業(yè)新機遇!

相關(guān)文章

熱門排行

信息推薦