如果满足第一个条件,则执行 blade elseif 条件语句结束

Do blade elseif conditionals end if the first condition is met

我在 blade 中有一个 elseif,如下所示:

@if(condition 1)
    Something 1
@elseif(condition 2)
    Something 2
@else
    Something 3
@endif

如果满足第一个条件并且发生了 Something 1,语句会完全结束,还是会同时触发 something 2,假设满足条件 2

第一个条件的主体将执行,然后结束。 如果你也想检查条件 2,那么你还需要将它设为 if 之外的 if else if 系列。

如果 else 语句语句在代码中对两个以上的条件执行不同,它将是这样的:

@if (condition 1)
    code to be executed only if this condition 1 is true;
@elseif (condition 2)
     code to be executed only if this condition 2 is true and condition 1 is false;
@else
     code to be executed if all conditions are false;
@endif

您可以在 php if else w3school 了解更多信息,它类似于 laravel blade 模板。