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 便利的地方還是在于碎片文件的復用,同時可以傳遞變量給碎片文件。