Home > PHP Framework > Laravel > body text

Detailed explanation of Laravel Blade template one-time components @once

藏色散人
Release: 2020-08-26 13:12:26
forward
2370 people have browsed it

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

@onceDetailed explanation of Laravel Blade template one-time components @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
Copy after login

The following is another example provided by Mohamed:<div class="code" style="position:relative; padding:0px; margin:0px;"><pre class="brush:php;toolbar:false;">@once &lt;template id=&quot;recieptsTemplate&quot;&gt; &lt;p class=&quot;flex flex-column items-center&quot;&gt; &lt;p class=&quot;w-1/2&quot; data-reciept=&quot;paid_at&quot;&gt;&lt;/p&gt; &lt;p class=&quot;w-1/4&quot; data-reciept=&quot;amount&quot;&gt;&lt;/p&gt; &lt;/p&gt; &lt;/template&gt; @endonce &lt;p data-id=&quot;receipts&quot; class=&quot;pide-y pide-grey-300&quot;&gt;&lt;/p&gt;</pre><div class="contentsignin">Copy after login</div></div> This is a receipt list. The receipt template only needs to be rendered once in the entire page, but the component itself can be called multiple times, which will not affect the receipt list structure. <p></p> <blockquote>You can use <p>once</p> directly in v7.25 and later Detailed explanation of Laravel Blade template one-time components @once versions. </blockquote> <p><code>Original address: https://laravel-news.com/laravel-blade-once-component

Translation address: https://learnku.com/laravel/t/ 48857

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!

Related labels:
source:learnku.com
Statement of this Website
The content of this article is voluntarily contributed by netizens, and the copyright belongs to the original author. This site does not assume corresponding legal responsibility. If you find any content suspected of plagiarism or infringement, please contact admin@php.cn
Popular Tutorials
More>
Latest Downloads
More>
Web Effects
Website Source Code
Website Materials
Front End Template
About us Disclaimer Sitemap
php.cn:Public welfare online PHP training,Help PHP learners grow quickly!