Home >PHP Framework >Laravel >Detailed explanation of Laravel Blade template one-time components @once
The following is a tutorial column to introduce you to the Detailed explanation of Laravel Blade template one-time components @once Blade template one-time component @once, I hope it will be helpful to friends who need it!
In Detailed explanation of Laravel Blade template one-time components @once 7.25 version, Blade has added a new component@once. This component is used to render a single tag. This may not be easy to understand. Let’s illustrate it through an example: pull request:
组件内容如下 @once <script> 无论该组件被渲染多少次,在模板中你只会看到一次输出。 </script> @endonce
The following is another example provided by Mohamed:<pre class="brush:php;toolbar:false;">@once
<template id="recieptsTemplate">
<p class="flex flex-column items-center">
<p class="w-1/2" data-reciept="paid_at"></p>
<p class="w-1/4" data-reciept="amount"></p>
</p>
</template>
@endonce
<p data-id="receipts" class="pide-y pide-grey-300"></p></pre>
You can useonce
directly in v7.25 and later Detailed explanation of Laravel Blade template one-time components @once versions.
Original address: https://laravel-news.com/laravel-blade-once-component
The above is the detailed content of Detailed explanation of Laravel Blade template one-time components @once. For more information, please follow other related articles on the PHP Chinese website!