blade notes

Components and Slots

add Components and Slots to Blade templates. This feature was inspired by Vue.js and allows you to simplify building HTML elements into reusable areas.

個人覺得 component & slot 組合,同 yield & section 組合的效果差不多。再想了一下,component 可以像 @include 一樣調用復用的碎片文件,這一點比 yield 功能要強大一些。在 component 區塊中,可以通過 @slot('variableName') @endslot 直接給父模板傳遞變量值,section 區塊也具有這個功能。綜合一下,感覺 component 便利的地方還是在于碎片文件的復用,同時可以傳遞變量給碎片文件。

Laravel Blade Components and Slots are coming to 5.4

最后編輯于
?著作權歸作者所有,轉載或內容合作請聯系作者
平臺聲明:文章內容(如有圖片或視頻亦包括在內)由作者上傳并發布,文章內容僅代表作者本人觀點,簡書系信息發布平臺,僅提供信息存儲服務。

推薦閱讀更多精彩內容