有 3 个 livewire 组件UserIsExpired
,每个组件分别有 3 个按钮UserIsActive
。UserIsPending
单击按钮时,它应该将先前的组件替换为其相应的组件。
<button wire:click="$emit(active)">{{ __('Active') }}</button>
<button wire:click="$emit(pending)">{{ __('Pending') }}</button>
<button wire:click="$emit(expired)">{{ __('Expired') }}</button>
在视图中
<livewire:user-is-active :active="$active"/>
<livewire:user-is-pending :pending="$pending"/>
<livewire:user-is-expired :expired="$expired"/>
组件示例
class UserIsExpired extends Component
{
protected $listeners = ['expired'];
public function render()
{
return <<<'blade'
<div>
{{-- The best athlete wants his opponent at his best. --}}
</div>
blade;
}
}
Active
单击按钮时,它应该加载UserIsActive
组件。其他两个也一样。
我一直在寻找 livewire doc,但无法找到如何实现它。提前致谢。