Link 的锚标记也在 Laravel Blade 中打印

Link of anchor tag is also printing in Laravel Blade

我有一份 table 的员工工资表。我用 anchor 标签包裹员工 ID,以显示每个员工的工资历史记录。问题是当我打印 table 时,个人工资历史记录的 link 也打印在员工 ID 下。

这里是截图打印预览:

Blade

<div class="d-section col-md-12">
    <table class="table table-striped table-condensed table-bordered">
        <thead>
        <tr>
            <th>ID</th>
            <th>Name</th>
            <th>Position</th>
            <th>Start Date</th>
            <th>End Date</th>
            <th>Worked</th>
            <th>Basic</th>
            <th>OT Rate</th>
            <th>OT Hour</th>
            <th>OT Amount</th>
            <th>Basic Amount</th>
            <th>Total</th>
            <th>Signature</th>
            <th>Finger</th>
        </tr>
        </thead>
        <tbody>
        @foreach($employees as $employee)
            <tr>
                <td><a href="{{ action('SalaryController@show',[$employee->id]) }}">{{ $employee->eid }}</a></td>
                <td>{{ $employee->name }}</td>
                <td>{{ $employee->designation }}</td>
                <td>{{ $employee->start }}</td>
                <td>{{ $employee->end }}</td>
                <td>{{ $employee->worked }}</td>
                <td>{{ $employee->basic }}</td>
                <td>{{ $employee->ot_rate }}</td>
                <td>{{ $employee->ot_hour }}</td>
                <td>{{ $employee->ot_amount }}</td>
                <td>{{ $employee->basic_amount }}</td>
                <td>{{ $employee->ot_amount + $employee->basic_amount }}</td>
                <td></td>
                <td>
                    {!! Form::open(['action'=>['SalaryController@destroy',$employee->id],'class'=>'no-print','method'=>'delete','onsubmit'=>'return deleteConfirm()']) !!}
                    {!! Form::submit('X',['class'=>'element btnn btn-danger']) !!}
                    <br/>
                    <a href="{{ action('SalaryController@edit',[$employee->id]) }}" class="element btnn btn-warning" role="button"><span class="glyphicon glyphicon-edit"></span></a>
                    <br/>
                    <a href="{{ action('SalaryController@payment',[$employee->id]) }}" class="element btnn btn-success" role="button"><span class="glyphicon glyphicon-usd"></span></a>
                    {!! Form::close() !!}
                </td>
            </tr>
        @endforeach
        </tbody>
    </table>
</div>

为什么不直接为您的锚创建一个 CSS class 并使用 class 隐藏它们?

<a href="{{ action('SalaryController@show',[$employee->id]) }}" class="hiddenTab">foo</a>
<a href="#" class="only-print">foo</a>

在你的 CSS 中:

.only-print{
    display:none;
}
@media print{
    a.hiddenTab {
        display:none;
    }
    .only-print{
        display:block;
    }
}

您想要隐藏的所有锚点只需使用 class="hiddenTab"。 如果你想隐藏所有设置了 href 的标签,你可以这样做:

a[href] { display: none; }