3 回答

TA貢獻(xiàn)1155條經(jīng)驗(yàn) 獲得超0個(gè)贊
//use url with route
//install axios
//define axios
var axios = require('axios');
axios({method: 'post',
url: baseUrl + '/persona_eliminar',
data: {_token: $('meta[name="csrf-token"]').attr('content'), id: id
}
})
.then(function (response) {
})

TA貢獻(xiàn)1804條經(jīng)驗(yàn) 獲得超8個(gè)贊
我相信標(biāo)準(zhǔn)語法是
function deletePersona (id) {
fetch('/persona_eliminar/' + id, {
method: 'POST',
body: JSON.stringify({
_method: 'PUT'
})
}).then((res) => res.json())
.then((response) => {
console.log(response)
})
}

TA貢獻(xiàn)1946條經(jīng)驗(yàn) 獲得超3個(gè)贊
即使使用路由的兼容方法,我個(gè)人也遇到了 fetch API 的問題。所以我改用 axios,它預(yù)裝了默認(rèn)的 Laravel 前端。
你可以這樣做:
axios.delete("/persona_eliminar/" + id)
.then((res) => {
//
})
這是我測(cè)試它的方法
路線::
Route::delete('/bounties/{bounty}/delete', 'BountyController@destroy');
Axios 演示:
添加回答
舉報(bào)