如果满足条件,我正在尝试显示包含变量的 HTML,否则只显示“测试”字样。
<a href="/StuffSpot/notifPost/{{ $notification->id }}">{{ $notification->read == 1 ? '<strong>{{$notification->send_uname}}</strong> has commented on <strong>{{$notification->title}}</strong> post' : 'test' }}</a>
我收到以下错误:
解析错误:语法错误,意外的 '}',期待 ',' 或 ')'
<a href="/StuffSpot/notifPost/{{ $notification->id }}">
@if($notification->read == 1)
<strong> {{ $notification->send_uname }}</strong> has commented on <strong>{{ $notification->title }}</strong> post
@else
test
@endif
</a>
尝试if
else
代替一行三元逻辑。
另外你已经使用{{ }}
了 echo out, don't use {{ }}
inside another, to display the html tags use {!! !!}
, laravel Blade{{ }}
将转义并回显这些字段内的 html 标签
本文收集自互联网,转载请注明来源。
如有侵权,请联系 [email protected] 删除。
我来说两句