ThinkChat2.0新版上线,更智能更精彩,支持会话、画图、阅读、搜索等,送10W Token,即刻开启你的AI之旅 广告
sidePagination只能是`'client'(默认)`或`'server'`。使用`'server'`时需要设置`'url'`或`'ajax'`选项。 [TOC] ## **没有服务器端分页** [bootstrap-table-examples/data1.json at master · wenzhixin/bootstrap-table-examples (github.com)](https://github.com/wenzhixin/bootstrap-table-examples/blob/master/json/data1.json) ``` [ { "id": 0, "name": "Item 0", "price": "$0", "amount": 3 }, { "id": 1, "name": "Item 1", "price": "$1", "amount": 4 }, { "id": 2, "name": "Item 2", "price": "$2", "amount": 8 }, { "id": 3, "name": "Item 3", "price": "$3", "amount": 2 }, { "id": 4, "name": "Item 4", "price": "$4", "amount": 90 }, { "id": 5, "name": "Item 5", "price": "$5", "amount": 2 }, { "id": 6, "name": "Item 6", "price": "$6", "amount": 3 }, { "id": 7, "name": "Item 7", "price": "$7", "amount": 7 }, { "id": 8, "name": "Item 8", "price": "$8", "amount": 39 }, { "id": 9, "name": "Item 9", "price": "$9", "amount": 78 }, { "id": 10, "name": "Item 10", "price": "$10", "amount": 30 }, { "id": 11, "name": "Item 11", "price": "$11", "amount": 32 }, { "id": 12, "name": "Item 12", "price": "$12", "amount": 12 }, { "id": 13, "name": "Item 13", "price": "$13", "amount": 76 }, { "id": 14, "name": "Item 14", "price": "$14", "amount": 10 }, { "id": 15, "name": "Item 15", "price": "$15", "amount": 9 }, { "id": 16, "name": "Item 16", "price": "$16", "amount": 8 }, { "id": 17, "name": "Item 17", "price": "$17", "amount": 1 }, { "id": 18, "name": "Item 18", "price": "$18", "amount": 99 }, { "id": 19, "name": "Item 19", "price": "$19", "amount": 100 }, { "id": 20, "name": "Item 20", "price": "$20", "amount": 109 } ] ``` ## **服务器端分页** ``` { "total": 200, "rows": [ { "id": 0, "name": "Item 0", "price": "$0" }, { "id": 1, "name": "Item 1", "price": "$1" }, { "id": 2, "name": "Item 2", "price": "$2" }, { "id": 3, "name": "Item 3", "price": "$3" }, { "id": 4, "name": "Item 4", "price": "$4" }, { "id": 5, "name": "Item 5", "price": "$5" }, { "id": 6, "name": "Item 6", "price": "$6" }, { "id": 7, "name": "Item 7", "price": "$7" }, { "id": 8, "name": "Item 8", "price": "$8" }, { "id": 9, "name": "Item 9", "price": "$9" }, { "id": 10, "name": "Item 10", "price": "$10" } ] } ``` 其中total和rows关键字可以通过dataField:'rows'和totalField:'total'更改 例:设置dataField:'items'、totalField:'count'返回的数据格式要求如下: ``` { "count": 200, "items": [ { "id": 0, "name": "Item 0", "price": "$0" }, { "id": 1, "name": "Item 1", "price": "$1" }, { "id": 2, "name": "Item 2", "price": "$2" }, { "id": 3, "name": "Item 3", "price": "$3" }, { "id": 4, "name": "Item 4", "price": "$4" }, { "id": 5, "name": "Item 5", "price": "$5" }, { "id": 6, "name": "Item 6", "price": "$6" }, { "id": 7, "name": "Item 7", "price": "$7" }, { "id": 8, "name": "Item 8", "price": "$8" }, { "id": 9, "name": "Item 9", "price": "$9" }, { "id": 10, "name": "Item 10", "price": "$10" } ] } ``` 如果格式不是`如果都不是以上格式,必须自己进行转换,这个时候,data-response-handler=``"responseHandler"``配置就起作用了` responseHandler参数 ``` ... url:'', responseHandler: function(res) { if (typeof $.table._option.responseHandler == "function") { $.table._option.responseHandler(res); } return { rows: res.data, total: res.total }; }, ... ```