blade用法

时间:2023-12-19 14:15:20

一、blade条件判断,foreach循环写法

@if(isset($fileInfo) && !empty($fileInfo))
  @foreach($fileInfo as $k)
  {{$k['name']}}
  @endforeach
@endif
<select name="fileID">
  <option value="">请选择</option>
@if(isset($fileInfo) && !empty($fileInfo))
@foreach($fileInfo as $k => $v)
  <option value="{{$k}}">{{ $v }}</option>
@endforeach
@else
@endif
</select>
@if(isset($fileInfo) && !empty($fileInfo))
{{ $fileInfo['is_last'] ? '是' : '否' }}
@elseif()
@elseif()
@endif

二、blade链接传参数写法

<a id="download" target="_blank" href="{{ url('folder/file') }}?fid={{$fileInfo['auto_id']}}&fname={{$fileInfo['name']}}">下载</a>
@if($fileInfo)
  <form class="form-horizontal" id="J_Form" method="post" action="{{ url('paper',$fileInfo['auto_id']) }}" autocomplete="off">
  <input type="hidden" name="_method" value="put">
@else
  <form class="form-horizontal" id="J_Form" method="post" action="{{ url('paper') }}">
@endif
<a class="grid" href="{{ url('folder/file') }}/'+id+'" target="_blank">查看</a>