【问题标题】:Laravel Blade Shows Special CharactersLaravel Blade 显示特殊字符
【发布时间】:2021-12-27 10:47:56
【问题描述】:

我正在处理一个需要从视图创建 PDF 的项目。但是在刀片文件中,“ß ß ß ß ß ß”字符,当我检查我的代码时,没有包含这些字符的标签。谁能帮我解决这个问题?我添加了刀片文件代码。请看一下。

    <html>
<html lang="en">

<head>
    <meta charset="utf-8">
    <link rel="stylesheet" href="https://cdn.jsdelivr.net/npm/bootstrap@4.6.0/dist/css/bootstrap.min.css" integrity="sha384-B0vP5xmATw1+K9KRQjQERJvTumQW0nPEzvF6L/Z6nronJ3oUOFUFpCjEUQouq2+l" crossorigin="anonymous">
    
</head>

<body>
    @if (count($data['data']) > 0)
        <table class="table table-condensed">
            <tr>
                <td><img src="{{public_path().'/theme/frontend/images/logo.png'}}"alt="kpvlogo"></td>
                <td colspan="8"  style="text-align: center; font-size:24px; font-weight: bold;">Weekly Ranking</td>
                <td colspan="6" >Week Ending {{$data['end']}}</td>
            </tr>
            <tr>
                <thead>
                    <th style="font-weight: bold;">Store</th>
                    <th style="font-weight: bold;">Net Sales</th>
                    <th style="font-weight: bold;">+/- Last Year %</th>
                    <th style="font-weight: bold;">Cust.Count +/- %</th>
                    <th style="font-weight: bold;">Labour %</th>
                    <th style="font-weight: bold;">Food %</th>
                    <th style="font-weight: bold;">Cash %</th>
                    <th style="font-weight: bold;">GSS</th>
                    <th style="font-weight: bold;">Complaints</th>
                    <th style="font-weight: bold;">Speed of Service</th>
                    <th style="font-weight: bold;">Training</th>
                    <th style="font-weight: bold;">Rank</th>
                </thead>
            </tr>
            <tbody>
                @foreach ($data['data']['grid'] as $item)
                    <tr>
                        <td>{{$item['store']}}</td>
                        <td class="text-right">{{$item['net_sales']}}</td>
                        <td class="text-right">{{$item['last_year']}}</td>
                        <td class="text-right">{{$item['customer_count']}}</td>
                        <td class="text-right">{{$item['labour']}}</td>ß
                        <td class="text-right">{{$item['food']}}</td>
                        <td class="text-right">{{$item['cash']}}</td>
                        <td class="text-right">{{$item['gss']}}</td>
                        <td class="text-right">{{$item['complaints']}}</td>
                        <td class="text-right">{{$item['speed_of_service']}}</td>
                        <td class="text-right">{{$item['training']}}</td>
                        <td class="text-right">{{$item['rank']}}</td>
                    </tr>
                @endforeach
                <tr>
                    <td colspan="12" class="text-center">Top Performer of the Week</td>
                </tr>
                <tr>
                    <td colspan="12" class="text-center">Congratulations to the team from <b>{{$data['data']['top']['store']}}</b>  for achieving the overall best results this week.</td>
                </tr>
                <tr>
                    <td colspan="12" class="text-center">Thank You!</td>
                </tr>
            </tbody>
            
        </table>
    @endif
    {{-- <script src="https://code.jquery.com/jquery-3.5.1.slim.min.js" integrity="sha384-DfXdz2htPH0lsSSs5nCTpuj/zy4C+OGpamoFVy38MVBnE+IbbVYUew+OrCXaRkfj" crossorigin="anonymous"></script>
    <script>
        var body_text = $('body').text();
        var match = body_text.match('ß');
        console.log(match);
    </script> --}}
    
</body>
</html>

【问题讨论】:

    标签: laravel special-characters laravel-blade


    【解决方案1】:

    如果您能确定特殊字符出现在刀片文件中的哪个位置,将会有所帮助。看到在您的刀片中找不到任何 ß ß ß ß ß ß 字符,这表明导致它的原因在您的数据库中的某个位置。我建议您检查看到字符的$item 的数据和数据库列,您可能会找到原因。

    【讨论】:

      猜你喜欢
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 2021-09-04
      相关资源
      最近更新 更多