【问题标题】:Blade Engine Elements Render Sorting刀片引擎元素渲染排序
【发布时间】:2018-02-14 07:35:20
【问题描述】:

我有这个代码:

<div class="table-responsive">
  <table class="table table-condensed table-hover">
    <tr>
    <th>#</th>
    <th>Name</th>
    <th>username</th>
    <th>Email</th>
    <th>Rank</th>
    <th>Join</th>
  </tr>
  @if($count)
      @foreach($users as  $i => $user)
      <tr>
      <td>{{ $i+1 }}</td>
      <td>{{ $user->first_name }} {{ $user->last_name }}</td>
        <td>{{ $user->username }}</td>
        <td>{{ $user->email }}</td>
        <td>
            @if($user->rank == 0)
              Admin
            @else
              User
            @endif
        </td>
        <td>{{ $user->created_at }}</td>
        {{ Form::hidden('id', $user->id,['class'=>'id']) }}
        {{ Form::hidden('username', $user->username,['class'=>'username']) }}
        <td><button id="submit" type="button" class="btn btn-danger" data-toggle="modal" data-target="#deleteModal">
          Delete
        </button></td>
      </tr>
      @endforeach
  @else
  <div class="alert alert-success" style="text-align:center">
      There is no users in the Site
  </div>
  @endif

它使用刀片模板引擎,但如果计数为假,则警报 div 会出现在表标题之前

如何解决这个问题?

【问题讨论】:

    标签: php html css laravel blade


    【解决方案1】:

    我可能在这里遗漏了一些东西,上面的代码似乎不完整(表格未关闭)。但是,如果您可以将它放在您需要的地方,为什么不将您的警报移到另一个之外:

    @if(!$count)
      <div class="alert alert-success" style="text-align:center">
      There is no users in the Site
      </div>
    @endif
    

    【讨论】:

    • 我忘了用代码关闭表格,好的,我现在试试
    猜你喜欢
    • 1970-01-01
    • 2016-03-17
    • 2016-04-04
    • 2018-10-03
    • 2011-05-05
    • 2013-06-08
    • 1970-01-01
    • 2015-03-05
    • 1970-01-01
    相关资源
    最近更新 更多