網上的回答都是以下這種:
axios.delete({
url: 'http://localhost:3000/todos',
data: {
"id": "a"
}
})
.then(function (response) {
console.log(response);
})
.catch(function (response) {
console.log(response);
});
但是親身試驗之後發現並不行
image.png
最後發現還是我的傳參出了問題,axios的傳參id是要直接加在URL後邊就可以,如下
axios.delete('http://localhost:3000/todos/' + id).then(function (res) {
console.log(res);
}).catch(function (err) {
console.log(err)
})
這個問題困擾了我大半個小時,終於解決了
作者:我歡喜喜歡你
鏈接:https://www.jianshu.com/p/85a0bb9436d0
來源:簡書
著作權歸作者所有。商業轉載請聯繫作者獲得授權,非商業轉載請註明出處。