close
如何在Laravel blade中使用include blade並且帶參數進去?
在include func中帶入第二個參數,把要帶進去的參數名稱和值用陣列包起來傳入。
ex:
@include('layouts.article', [
'mainTitle' => "404, page not found",
'mainContent' => "sorry, but the requested page does not exist :("
])
--
It's not a bug but a limitation of blade syntax due to regex. Solution came from github:
The problem is using multi-line. You can only use a single line to [pass variables] in Blade, since syntax is limited [by regular expressions]
Try the code below and you should be good to go:
@include('layouts.article', ['mainTitle' => "404, page not found", 'mainContent' => "sorry, but the requested page does not exist :("])
--
全站熱搜
留言列表