【问题标题】:How to create a new data in Laravel Livewire without refresh the page如何在 Laravel Livewire 中创建新数据而不刷新页面
【发布时间】:2022-11-14 10:09:28
【问题描述】:

我对 Laravel Livewire CRUD 应用程序有疑问。当我在成功插入并重置表单后创建数据时,我无法创建新数据。我应该刷新页面然后创建新数据。不刷新页面就不允许我创建数据。

存储功能是:

public function store()
{
     $this->validate();
      auth()->user()->reminders()->create([
          'body' => $this->body,
          'frontend' => $this->frontend,
          'date' => $this->date,
          'time' => $this->time,
      ]);
      $this->resetInputs();
}

【问题讨论】:

    标签: laravel-livewire livewires


    【解决方案1】:
    use submit.prevent
    <form wire:submit.prevent="store">
    do not use button click
     <button wire:click="store">Craate</button>
    </form>
    
    

    【讨论】:

      猜你喜欢
      • 2021-09-02
      • 2016-02-04
      • 2014-07-04
      • 1970-01-01
      • 2011-12-22
      • 2012-02-22
      • 2016-07-16
      • 2016-09-03
      • 2021-12-23
      相关资源
      最近更新 更多