【发布时间】:2021-03-03 09:44:40
【问题描述】:
我有一个包含多个模态的表,我正在尝试测试在循环中传递行 id 以确保我的模态正常工作。但我无法通过我的 Livewire 组件显示变量的值。
Livewire 组件
<livewire:dashboard.actions :apt_id="$appointments->id"/>
Livewire/dashboard/actions.blade.php
<div><button wire:click="showModal">Show modal</button>
<x-jet-dialog-modal wire:model="showingModal">
<x-slot name="title">
{{ __('Delete Account') }}
</x-slot>
<x-slot name="content">
{{ $apt_id }}
</x-slot>
<x-slot name="footer">
<x-jet-secondary-button wire:click="$toggle('showingModal')" wire:loading.attr="disabled">
{{ __('Nevermind') }}
</x-jet-secondary-button>
<x-jet-danger-button class="ml-2" wire:click="deleteUser()" wire:loading.attr="disabled">
{{ __('Delete Account') }}
</x-jet-danger-button>
</x-slot>
</x-jet-dialog-modal></div>
Livewire/Dashboard/Actions.php
class Actions extends Component {
public $showingModal = '';
public $apt_id;
public function mount($apt_id)
{
$this->apt_id = $apt_id;
}
public function showModal()
{
$this->showingModal = true;
}
public function render()
{
return view('livewire.dashboard.actions');
}}
【问题讨论】:
-
你确定它传递了你假设的值吗?在您的
mount()方法中执行dd($apt_id);进行检查。
标签: php laravel laravel-blade laravel-livewire