【问题标题】:Laravel: Missing Argument error on a POSTLaravel:POST 上缺少参数错误
【发布时间】:2020-09-09 20:40:57
【问题描述】:

我不断收到错误 "Missing argument 1 for App\Http\Controllers\Users::deleteMobileAssets()" 。我正在使用 Vue 从我的前端拨打电话。当我检查标题时,它似乎是正确的,但我不确定是什么导致了错误。我也尝试将 imageType 括在括号中:{imageType: imageType} 但仍然是同样的错误。

deleteImage(imageType) {
    axios.post('/delete-mobile-assets', imageType);
}

 public function deleteMobileAssets($imageType)
{

}

【问题讨论】:

    标签: laravel vue.js


    【解决方案1】:

    POST 数据包含在请求正文中,因此您会收到 Missing argument 1. 试试这个

    deleteImage(imageType) {
        axios.post('/delete-mobile-assets', {imageType:imageType});
    }
    
    public function deleteMobileAssets(Request $request)
    {
      $request->imageType
    }
    

    或者如果你想实现 DELETE 方法。看看Delete Method in Axios, Laravel and VueJS

    【讨论】:

      猜你喜欢
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 2021-03-16
      • 2012-03-04
      • 2019-10-25
      相关资源
      最近更新 更多