我有这个代码在页面加载时触发jQuery slideUp一些元素:
@if(request()->cookie('pin-toolbox-for-objects') == 1)
<?php $show_toolbox_objects = ''; ?>
@else
<?php $show_toolbox_objects = 'data-more-close';?>
@endif
<div {{$show_toolbox_objects}} id="toolbox">
@include('navs._toolbox_object_buttons')
</div>
有没有办法改进此代码?
答案 0 :(得分:0)
这会更优雅:
<div <?php (request()->cookie('pin-toolbox-for-objects') == 1)?'test':'data-more-close'?> id="toolbox">
但它没有工作。令人惊讶的是,这个确实如此:
<div @if(request()->cookie('pin-toolbox-for-objects') == 1) data-more-close @endif id="toolbox">