【问题标题】:How to submit a form in Laravel Vue component如何在 Laravel Vue 组件中提交表单
【发布时间】:2020-05-28 05:01:38
【问题描述】:

我在尝试提交的 laravel vue 组件中创建了一个,但我收到 404 错误 ThoughtJournalController@store not found。

<form method="POST" action="{{ action('ThoughtJournalController@store') }}">

如何在 vue 组件中正确提交表单?

【问题讨论】:

    标签: html laravel vue.js


    【解决方案1】:

    在resources/routes/web.php中创建路由:

    Route::post( '/submit', 'ThoughtJournalController@store' );
    

    然后编辑您的表单:

    <form method="POST" action="/submit">
    

    【讨论】:

    • 我收到一个错误:action="{{ route('storeEntry') }}":属性内的插值已被删除。请改用 v-bind 或冒号简写。例如,使用
      代替
    • 尝试在您的操作中键入相对路径。像这样:动作=“提交/路径”。与Route::get()的第一个属性相同的路径
    • 您的表单在 *.vue 文件中而不是在 *.blade.php 文件中,对吧?
    • 为了在 .vue 组件中使用 laravel 命名路由,您可以使用 github.com/tightenco/ziggy
    • 是 .vue 文件中的表单
    【解决方案2】:

    您好像忘记定义路线了:

        Route::get('posts', 'ThoughtJournalController@store');
    

    【讨论】:

      猜你喜欢
      相关资源
      最近更新 更多
      热门标签