微信公众号搜"智元新知"关注
微信扫一扫可直接关注哦!

使可重用组件Laravel Livewire

如何解决使可重用组件Laravel Livewire

我想通过下面的代码制作可重用的带电电线组件

searchfilm.blade.PHP

             @foreach ($inputs as $key => $value)
                    <div class="input-group-append">
                        <select class="custom-select" wire:model="selectServer.{{ $value }}">
                            <option value="" selected>Server Name</option>
                            @foreach ($servers as $idData => $nameData)
                                <option value="{{ $idData }}">{{ $nameData }}</option>
                            @endforeach
                        </select>
                    </div>
                    **<div class="input-group-append">
                        <select class="custom-select" wire:model="selectQuality.{{ $value }}">
                            <option value="" selected>Quality</option>
                            @foreach ($qualities as $idData => $nameData)
                                <option value="{{ $idData }}">{{ $nameData }}</option>
                            @endforeach
                        </select>
                    </div>**
                </div>
            @endforeach

我尝试将其更改为

searchfilm.blade.PHP

@foreach ($inputs as $key => $value)
     @livewire('dropdown',['title' => 'Server Name','data' => $servers,'x' => $value])
     @livewire('dropdown',['title' => 'Quality','data' => $qualities,'x' => $value])
@endforeach

dropdown.blade.PHP

<div>
    <div class="input-group-append">
        <select class="custom-select" wire:model="selectData.{{ $x }}">
            <option value="" selected>{{ $title }}</option>
            @foreach ($data as $idData => $nameData)
                <option value="{{ $idData }}">{{ $nameData }}</option>
            @endforeach
        </select>
    </div>
</div>

但不起作用,有任何建议

版权声明:本文内容由互联网用户自发贡献,该文观点与技术仅代表作者本人。本站仅提供信息存储空间服务,不拥有所有权,不承担相关法律责任。如发现本站有涉嫌侵权/违法违规的内容, 请发送邮件至 dio@foxmail.com 举报,一经查实,本站将立刻删除。