【问题标题】:data attributes in a bootstrap-table data table causes an infinite loops引导表数据表中的数据属性导致无限循环
【发布时间】:2021-08-29 15:57:40
【问题描述】:

我正在尝试使用引导表在表中输出数据。它输出数据,但在说“正在加载,请稍候”时导致无限循环。如果有帮助,我也在使用树枝。我不确定我做错了什么,因为遵循了https://bootstrap-table.com/docs/getting-started/usage/的模板

这是我的代码

<div class="row mt-md-3">
    <div class="container">
        <div class="card">
            <div class="card-body">
                <div class="card-title pt-3 text-center h4">Site List</div>   
                <table  
                        data-toggle="table"
                        data-pagination="true"
                        data-search="true" 
                        data-page-list="[10, 25, 50, 100, all]"
                        data-show-columns="true"
                        >
                    <thead>
                        <tr>
                            <th data-sortable="true">Site Id</th>
                            <th data-field="domain">Domain Name</th>
                            <th data-field="total">Total Students</th>
                        </tr>
                    </thead>
                    {% for si in data.dashboard.SiteInfo %}
                        <tbody>
                            <tr>
                                <td>{{si.SiteId}}</th>
                                <td>{{ si.SiteName }}</td>
                                <td>{{si.TotalStudents}}</td>
                            </tr>
                        </tbody>
                    {% endfor %}
                </table>
            </div>
        </div>
    </div>    
</div>

【问题讨论】:

    标签: php twig bootstrap-table


    【解决方案1】:

    您每次都在创建新的&lt;tbody&gt; 尝试在 for 循环之前创建它

    <tbody>
    {% for si in data.dashboard.SiteInfo %}
               <tr>
                   <td>{{si.SiteId}}</th>
                   <td>{{ si.SiteName }}</td>
                   <td>{{si.TotalStudents}}</td>
                 </tr>
                            
     {% endfor %}
    </tbody>
    

    【讨论】:

    • 我已经坚持了 2 天。这解决了它。谢谢!
    猜你喜欢
    • 1970-01-01
    • 2021-07-17
    • 2021-10-30
    • 1970-01-01
    • 1970-01-01
    • 2016-05-31
    • 2021-12-20
    • 1970-01-01
    • 1970-01-01
    相关资源
    最近更新 更多