[英]My delete function | method can not delete in Laravel Vuejs
This is why i can't delete by ID, even the code is inactive at id, its a JS file.这就是为什么我不能按 ID 删除的原因,即使代码在 id 处处于非活动状态,它是一个 JS 文件。
This is my delete function in controller这是我在控制器中的删除功能
> public function destroy(Estate $estates)
> {
> if ($estates->delete()) {
> return response()->json([
> 'message' => 'Estate deleted successfully',
> 'status_code' => 200
> ], 200);
> } else {
> return response()->json([
> 'message' => 'Can not delete, Some error occured, please try again later',
> 'status_code' => 500
> ], 500);
> }
> }
Below is my Vue method to initiate the delete method first is my button second is my delete method下面是我的 Vue 方法来启动删除方法,首先是我的按钮,其次是我的删除方法
<button class="btn btn-danger btn-sm" v-on:click="deleteEstate(estate)"> <span class="fas fa-trash-alt"></span></button>
> deleteEstate: async function(estate) {
> if (!window.confirm('Are You sure you want to delete this Estate Record!')) {
> return;
> }
>
> try {
> await estateService.deleteEstate(estate.id);
>
> this.estate = this.estate.filter(obj => {
> return obj.id != estate.id;
> });
> } catch (error) {
>
> }
> }
this is my result on delete, need some help!这是我删除的结果,需要一些帮助!
You are sending /estate/{id} to your backend.您正在将 /estate/{id} 发送到您的后端。 You should wrap the string in backticks `.
您应该将字符串包裹在反引号 ` 中。
In your deleteEstate()
you're using single quotes '' but ${}
operator needs the backquote `` in order to work.在您的
deleteEstate()
您使用单引号 '' 但${}
运算符需要反引号 `` 才能工作。 Try changing it.尝试改变它。
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.