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

最后编辑于
©著作权归作者所有,转载或内容合作请联系作者
平台声明:文章内容(如有图片或视频亦包括在内)由作者上传并发布,文章内容仅代表作者本人观点,简书系信息发布平台,仅提供信息存储服务。

推荐阅读更多精彩内容