San*_*rez 6 laravel laravel-livewire
我已经开始使用 livewire,但我无法让它工作,我使用 awire:click在创建模式或编辑模式下加载表单,但是当我单击时,我得到的只是某种带有 404 错误的模式
这是 Livewire 组件
namespace App\Http\Livewire;
use Livewire\Component;
class Activities extends Component
{
public $view = 'none';
public function render()
{
return view('livewire.activities');
}
public function create_view(){
$this->view = 'create';
}
public function edit(){
$this->view = 'edit';
}
}
Run Code Online (Sandbox Code Playgroud)
这就是观点
<button wire:click="create_view" class="button-warning">{{ __('Create') }}</button>
@if ($view != 'none')
<div class="col-span-6">
@include("livewire.$view")
</div>
@endif
Run Code Online (Sandbox Code Playgroud)
编辑:我手动加载视图并且它加载正确,例如:
@if ($view != 'none')
<div class="col-span-6">
@include("livewire.edit")
</div>
@endif
Run Code Online (Sandbox Code Playgroud)
如果像您所说的那样,那么您必须检查 $view 值。关闭视图时请务必记住将属性更改为默认值。
@if ($view != 'none')
<div class="col-span-6">
@include("livewire.edit")
</div>
@endif
Run Code Online (Sandbox Code Playgroud)
| 归档时间: |
|
| 查看次数: |
2320 次 |
| 最近记录: |