dongpu5874 2017-05-24 05:29
浏览 55
已采纳

如何在视图laravel刀片上添加类中的操作符三元组?

I try like this :

@for($i = 0; $i < 5; $i++) 
...
    <div class="image ($i==0) ? 'image-main' : ''">
...
@endfor

But it does not work.

It seems the way of writing is incorrect.

How can I solve this problem?

  • 写回答

4条回答 默认 最新

  • dongxian3852 2017-05-24 05:35
    关注

    In laravel's blade file you need to use {{}} to execute php code.

    {{ ($i == 0) ? 'image-main' : '' }}
    
    本回答被题主选为最佳回答 , 对您是否有帮助呢?
    评论
查看更多回答(3条)

报告相同问题?