小编Jar*_*rez的帖子

Livewire - 检测到多个根元素

我正在创建一个表,其行包含在 Livewire 组件内

\n
<div class="card">\n    <div class="card-body">\n        <table class="table table-hover table-striped">\n            <thead>\n                <tr>\n                    <th>Nombre del Riesgo</th>\n                    <th>Informaci\xc3\xb3n</th>\n                    <th>Due\xc3\xb1o del Riesgo</th>\n                    <th>Costo Adicional</th>\n                    <th>Prevenci\xc3\xb3n</th>\n                </tr>\n            </thead>\n            <tbody>\n                <div>\n                    @foreach($risks as $risk)\n                        <livewire:risk-row :risk="$risk"/>\n                    @endforeach\n                </div>\n            </tbody>\n        </table>\n    </div>\n</div>\n
Run Code Online (Sandbox Code Playgroud)\n

但在行组件中,每当我更改输入或从下拉选择中选择某些内容时,该组件都不会重新渲染。

\n

我想知道为什么会发生这种情况。所以我打开控制台并看到:

\n
Livewire: Multiple root elements detected. This is not supported. See docs for more information https://laravel-livewire.com/docs/2.x/troubleshooting#root-element-issues <div wire:id=\xe2\x80\x8b"6CNMP1hiBR3Qy7IbmfbQ">\xe2\x80\x8b \xe2\x80\x8b</div>\xe2\x80\x8b\nvalue @ index.js:85\nComponent @ index.js:27\n(anonymous) @ index.js:88\nvalue @ index.js:87\n(anonymous) @ schedule:432\n
Run Code Online (Sandbox Code Playgroud)\n

这是组件刀片文件

\n
Livewire: Multiple root elements detected. This …
Run Code Online (Sandbox Code Playgroud)

laravel laravel-livewire

4
推荐指数
1
解决办法
1万
查看次数

标签 统计

laravel ×1

laravel-livewire ×1