wire:init
Livewireは、コンポーネントがレンダリングされた直後にアクションを実行するためのwire:init
ディレクティブを提供します。これは、ページ全体のロードを遅らせたくないが、ページロード直後にいくつかのデータをロードしたい場合に役立ちます。Livewire offers a wire:init
directive to run an action as soon as the component is rendered. This can be helpful in cases where you don't want to hold up the entire page load, but want to load some data immediately after the page load.
<div wire:init="loadPosts">
<!-- ... -->
</div>
loadPosts
アクションは、Livewireコンポーネントがページにレンダリングされた直後に実行されます。The loadPosts
action will be run immediately after the Livewire component renders on the page.
ほとんどの場合、wire:init
を使用するよりも、Livewireの遅延ロード機能を使用する方が望ましいです。In most cases however, Livewire's lazy loading feature[/docs/lazy] is preferable to using wire:init
.