添加 Infolist 到 Livewire 组件
准备 Livewire 组件
首先,生成新的 Livewire 组件:
php artisan make:livewire ViewProduct
然后,在页面上渲染 Livewire 组件:
@livewire('view-product')
或者,你可以使用整页 Livewire 组件:
use App\Livewire\ViewProduct;
use Illuminate\Support\Facades\Route;
Route::get('products/{product}', ViewProduct::class);
你必须使用 InteractsWithInfolists
和 InteractsWithForms
traits,并在你的 Livewire 组件类中实现 HasInfolists
和 HasForms
接口:
use Filament\Forms\Concerns\InteractsWithForms;
use Filament\Forms\Contracts\HasForms;
use Filament\Infolists\Concerns\InteractsWithInfolists;
use Filament\Infolists\Contracts\HasInfolists;
use Livewire\Component;
class ViewProduct extends Component implements HasForms, HasInfolists
{
use InteractsWithInfolists;
use InteractsWithForms;
// ...
}