Laravel是否有@includeIfElse指令可供选择?
基本上,我想包括另一个模板,如果它存在,否则包括另一个模板。
这个功能存在吗?我怎样才能做到这一点?
发布于 2016-11-29 21:41:30
不,没有这样的指令,但您可以使用这样的命令:
@if(view()->exists('view.name'))
@include('view.name')
@else
@include('other.view.name')
@endif发布于 2016-11-30 05:40:56
如果你觉得有必要的话,我想你可以这样说:
@include(view()->exists('view.name') ? 'view.name' : 'other.view.name')https://stackoverflow.com/questions/40876017
复制相似问题