此路由不支持 PUT 方法。 Vue/laravel

The PUT method is not supported for this route. Vue/laravel

当我尝试更新产品时,我的 vue 组件出现问题 returns 不支持错误放置方法...但应该支持它。

我的EditProduct.vue

<form @submit.prevent="submitForm">
   <div class="form-group row">
     <label for="name" class="col-md-4 col-form-label text-md-right">Name:</label>
     <input type="text" name="name" id="name" v-model="product.name">
   </div>
   <div class="form-group row">
     <label class="col-md-4 col-form-label text-md-right">Description:</label>
     <textarea name="description" cols="20" rows="5" v-model="product.description"></textarea>
   </div>
   <div style="display: flex; justify-content: center">
     <button type="submit">Save</button>
   </div>
</form>

我的提交方法:(我试过 patch/put 代替 axios.post 但它仍然不起作用)

    submitForm(){
        let data = new FormData();
        data.append('_method', 'PUT');
        data.append('id', this.product.id);
        data.append('name', this.product.name);
        data.append('description', this.product.description);
        axios.post('edit', data)
        .then( (response) => {
            console.log("success");
        })
    }

我的api路线:

Route::put('/edit', [ProductController::class, 'update']);

我做错了什么?

正如我发布问题一样,我意识到 axios 的 url 是错误的,它应该是

/api/edit

现在有效:)