首页 > 解决方案 > 未捕获的类型错误:无法使用 laravel 读取未定义的属性“mData”

问题描述

我有下表:

     <div class="row">
            <div class="col-12 mb-4 data-table-rows data-tables-hide-filter">
                <table id="datatableRows" class="data-table responsive nowrap"
                    data-order="[[ 1, &quot;desc&quot; ]]">
                    <thead>
                        <tr>
                            <th>Name</th>
                            <th>Sales</th>
                            <th>Stock</th>
                            <th>Category</th>
                            <th>test</th>
                            <th>test2</th>
                           <!--  <th class="empty">&nbsp;</th>  -->
                        </tr>
                    </thead>
                    <tbody>
                          @foreach($castings as $cast)
                        <tr>
                            <td>
                                <p class="list-item-heading">{{ $cast->casting_name }}</p>
                            </td>
                            <td>
                               <p class="text-muted">{{ $cast->casting_cin }}</p>
                            </td>
                            <td>
                               <p class="text-muted">{{ $cast->casting_email }}</p>
                            </td>
                            <td>
                                <p class="text-muted">{{ $cast->casting_phone }}</p>
                            </td>
                           <td>
                               <p class="text-muted">{{ $cast->casting_city }}</p>
                            </td>
                            <td>
                                <p class="text-muted">{{ $cast->casting_address}}</p>
                            </td> 
                        </tr>
                            @endforeach
                    </tbody>
                </table>
            </div>
        </div>

但是当我执行我的代码时出现这个错误:

datatables.min.js:101 Uncaught TypeError: Cannot read property 'mData' of undefined
at HTMLTableCellElement.<anonymous> (datatables.min.js:101)

它包含<thead><tbody>标签,

列数也相等

我看不出问题出在哪里

如果你有任何想法请帮助我

标签: jquerylaravel

解决方案


推荐阅读