php - Livewire/Blade 组件中的渲染变量
问题描述
我有一个包含多个模态的表,我正在尝试测试在循环中传递行 id 以确保我的模态正常工作。但我无法通过我的 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/仪表板/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()
变量并将其更改为 camelCase。
推荐阅读
- javascript - TypeError: Cannot read property 'match' of undefined ( react and graphql )
- mysql - MySQL 8.0 命令行客户端在输入正确密码后立即崩溃
- visual-studio-code - 可以在运行时编辑 VSCode 扩展 package.json 吗?
- javascript - 更新firebase云场角度
- javascript - 即使密码匹配,确认密码仍显示“密码不匹配”
- python - 自动加入创建组的用户
- function - 在 Julia 中调用函数的正确方法
- ios - 如何在 UILabel 中绘制上划线?
- react-native - 你如何在 React Native 中的应用地图中获得传统的蓝色地图标记?
- android - 是否可以通过Android使用MPAndroidChart垂直绘制折线图值?