html+vue實(shí)現(xiàn)分頁功能的示例代碼
實(shí)現(xiàn)效果:

html關(guān)鍵代碼:
<div class="ui-jqgrid-resize-mark" id="rs_mlist_table_C87E35BE"> </div>
<div class="list_component_pager ui-jqgrid-pager undefined" dir="ltr">
<div id="pg_list_table_C87E35BE_pager" class="ui-pager-control" role="group">
<table class="ui-pg-table ui-common-table ui-pager-table table table-sm">
<tbody>
<tr>
<td id="list_table_C87E35BE_pager_left" align="left"></td>
<td id="list_table_C87E35BE_pager_center" align="center"
style="white-space: pre; width: 370.844px;">
<table class="ui-pg-table ui-common-table ui-paging-pager">
<tbody>
<tr>
<td ng-show="pageNum<=1" class="ui-pg-button undefined ui-disabled"
title="第一頁">
<span class="bi bi-chevron-bar-left"></span>
</td>
<td ng-show="pageNum>1" class="ui-pg-button undefined" title="第一頁"
ng-click='ctrl.firstPage()'>
<span class="bi bi-chevron-bar-left"></span>
</td>
<td ng-show="pageNum<=1" class="ui-pg-button undefined ui-disabled"
title="上一頁">
<span class="bi bi-chevron-left"></span>
</td>
<td ng-show="pageNum>1" class="ui-pg-button undefined" title="上一頁"
ng-click='ctrl.upperPage()'>
<span class="bi bi-chevron-left"></span>
</td>
<td class="ui-pg-button ui-disabled" style="cursor: default;">
<span class="ui-separator"></span>
</td>
<td id="input_list_table_C87E35BE_pager" dir="ltr">
<input class="ui-pg-input undefined" type="text" size="2" maxlength="7"
ng-model="pageNum" role="textbox"> 共
<span id="sp_1_list_table_C87E35BE_pager">{{totalPages}}</span>頁
</td>
<td class="ui-pg-button ui-disabled" style="cursor: default;">
<span class="ui-separator"></span>
</td>
<td ng-show="totalPages==pageNum"
class="ui-pg-button undefined ui-disabled"
title="下一頁"
style="cursor: default;">
<span class="bi bi-chevron-right"></span>
</td>
<td ng-show="pageNum>=1&&totalPages>1&&pageNum!=totalPages"
class="ui-pg-button undefined"
title="下一頁"
ng-click='ctrl.nextPage()'
style="cursor: default;">
<span class="bi bi-chevron-right"></span>
</td>
<td ng-show="pageNum<totalPages"
class="ui-pg-button undefined" title="最后一頁"
ng-click='ctrl.lastPage()'>
<span class="bi bi-chevron-bar-right"></span>
</td>
<td ng-show="pageNum>=totalPages"
class="ui-pg-button undefined ui-disabled"
title="最后一頁">
<span class="bi bi-chevron-bar-right"></span>
</td>
<td style="margin-top: 20px;">
<cb-select style="border: 1px solid #f0f0f0;margin-top: 20px;"
ng-model="statType" options="statTypeOptions"
ng-change='ctrl.flippingPage()'
inline="true" title="每頁記錄數(shù)">
</cb-select>
<!-- <select class="ui-pg-selbox undefined" size="1" role="listbox"-->
<!-- title="每頁記錄數(shù)">-->
<!-- <option role="option" value="15" selected="selected">15</option>-->
<!-- <option role="option" value="50">50</option>-->
<!-- <option role="option" value="100">100</option>-->
<!-- </select>-->
</td>
</tr>
</tbody>
</table>
</td>
<td id="list_table_C87E35BE_pager_right" align="right">
<div dir="ltr" style="text-align:right" class="ui-paging-info">{{test1}}-{{test2}} 共
{{count}} 條
</div>
</td>
</tr>
</tbody>
</table>
</div>
</div>vue代碼:
$scope.statTypeOptions = [{id: '1', name: '15'}, {id: '2', name: '50'}, {id: '3', name: '100'}];
$scope.statType = $scope.statTypeOptions[0];
$scope.count = '';//總數(shù)
$scope.test1 = '';//開始頁數(shù)
$scope.test2 = '';//結(jié)束頁數(shù)
$scope.totalPages = '';//總頁數(shù)
$scope.pageNum = '';//頁碼
$scope.pageSize = '';//每頁數(shù)
$scope.lastSize = '';//最后一頁 initialize: function () {
ctrl.initData();
},
initData: function () {
ctrl.getList(ctrl.filter.keyword, ctrl.filter.dateRange, ctrl.filter.dateRanges, $scope.pageNum, $scope.pageSize)
},
getList: function (keyword, dateRange, dateRanges, pageNum, pageSize) {
http.get('maintenanceRecords/total', {
keyword: keyword,
dateRange: util.encodeJSON(dateRange),
dateRanges: util.encodeJSON(dateRanges),
pageNum: pageNum, pageSize: pageSize
}).then(function (response) {
var result = _.get(response, 'data.datas.result', {});
$scope.entity = result.list;
$scope.count = result.count;
$scope.totalPages = result.totalPages;
$scope.pageNum = result.pageNum;
$scope.pageSize = result.pageSize;
if ($scope.pageNum == '1') {
$scope.test1 = '1'
$scope.test2 = $scope.count
} else {
$scope.test1 = $scope.pageSize * 1 + 1
if ($scope.pageSize * $scope.pageNum <= $scope.count) {
$scope.test2 = $scope.pageSize * $scope.pageNum
} else {
$scope.test2 = $scope.count
}
}
$scope.lastSize = Math.ceil($scope.totalPages / $scope.pageSize);
util.apply($scope);
});
},
firstPage: function () {
ctrl.getList(ctrl.filter.keyword, ctrl.filter.dateRange, ctrl.filter.dateRanges, '1', $scope.pageSize)
},
upperPage: function () {
$scope.pageNum = $scope.pageNum * 1 - 1
ctrl.getList(ctrl.filter.keyword, ctrl.filter.dateRange, ctrl.filter.dateRanges, $scope.pageNum, $scope.pageSize)
},
nextPage: function () {
$scope.pageNum = $scope.pageNum * 1 + 1
ctrl.getList(ctrl.filter.keyword, ctrl.filter.dateRange, ctrl.filter.dateRanges, $scope.pageNum, $scope.pageSize)
},
lastPage: function () {
$scope.pageNum = Math.ceil($scope.count * 1 / $scope.pageSize * 1);
ctrl.getList(ctrl.filter.keyword, ctrl.filter.dateRange, ctrl.filter.dateRanges, $scope.pageNum, $scope.pageSize)
},
flippingPage: function () {
$scope.pageSize = $scope.statType.name
ctrl.getList(ctrl.filter.keyword, ctrl.filter.dateRange, ctrl.filter.dateRanges, $scope.pageNum, $scope.pageSize)
},Java后端代碼:
@GetMapping("/total")
public CheckMessage total(@RequestParam(value = "keyword", required = false) String keyword,
@RequestParam(value = "dateRanges", required = false) String dateRanges,
@RequestParam(value = "dateRange", required = false) String dateRange,
@RequestParam(value = "pageNum", required = false, defaultValue = "1") Integer pageNum,
@RequestParam(value = "pageSize", required = false, defaultValue = "15") Integer pageSize) {
Document userDoc = UserUtils.getUser();
Document query = new Document();
//維修單編號(hào)、狀態(tài)、產(chǎn)品類型、產(chǎn)品編碼、產(chǎn)品名稱、SN碼(新舊碼一起搜索)、處理方案、創(chuàng)建日期、維修完成日期
if (StrUtil.isNotEmpty(keyword)) {
query = new Document()
.append("$or", Arrays.asList(
new Document("repairOrderNumber", new Document("$regex", keyword)),
new Document("orderWorkStatus", new Document("$regex", keyword)),
new Document("appraisal.service.name", new Document("$regex", keyword)),
new Document("product.type", new Document("$regex", keyword)),
new Document("product.code", new Document("$regex", keyword)),
new Document("product.name", new Document("$regex", keyword)),
new Document("snCode", new Document("$regex", keyword)),
new Document("resultsRepair.newSnCode", new Document("$regex", keyword)),
new Document("resultsRepair.machine", new Document("$regex", keyword))));
}
if (UserUtils.isOEMUser()) {
Document oemDto = userDoc.get("oem", Document.class);
query.append("oemCode", oemDto.getString("id"));
}
if (StrUtil.isNotEmpty(dateRange)) {
Document entity = DocuLib.parseDecode(dateRange);
if (entity.size() > 0) {
query.append("$and", Arrays.asList(
new Document("createTime", new Document("$gte", entity.getString("start"))),
new Document("createTime", new Document("$lte", entity.getString("end")))
));
}
}
if (StrUtil.isNotEmpty(dateRanges)) {
Document entity = DocuLib.parseDecode(dateRanges);
if (entity.size() > 0) {
query.append("$and", Arrays.asList(
new Document("completedRepairData", new Document("$gte", entity.getString("start"))),
new Document("completedRepairData", new Document("$lte", entity.getString("end")))
));
}
}
// 計(jì)算跳過的記錄數(shù)
int skipCount = (pageNum - 1) * pageSize;
List<Document> list = DBUtils.list(MaintenanceRecords.collectionName, query, null, null, pageSize, skipCount);
//總數(shù)
long count = DBUtils.count(MaintenanceRecords.collectionName, query);
// 計(jì)算總頁數(shù)
int totalPages = (int) Math.ceil((double) count / pageSize);
Document entity = new Document();
entity.put("list", list);
entity.put("count", count);
entity.put("pageNum", pageNum);
entity.put("pageSize", pageSize);
entity.put("totalPages", totalPages);
return ResultData.succ(entity);
}到此這篇關(guān)于html+vue實(shí)現(xiàn)分頁功能的示例代碼的文章就介紹到這了,更多相關(guān)vue分頁內(nèi)容請(qǐng)搜索腳本之家以前的文章或繼續(xù)瀏覽下面的相關(guān)文章希望大家以后多多支持腳本之家!
- 前端開發(fā)之html,css,JavaScript和vue關(guān)系詳解
- 前端如何調(diào)用Go語言后端接口(HTML?+?JS?&?Vue)
- Vue項(xiàng)目中平滑地引入HTML文件的五種方法實(shí)現(xiàn)與對(duì)比
- 如何將HTML頁面改寫到vue項(xiàng)目中詳解
- 在vue中實(shí)現(xiàn)iframe嵌套Html頁面及注意事項(xiàng)說明
- vue的index.html中獲取環(huán)境變量和業(yè)務(wù)判斷圖文詳解
- Vue+HTML5+AI實(shí)現(xiàn)智能前端應(yīng)用開發(fā)的技術(shù)原理與實(shí)踐代碼
相關(guān)文章
vue監(jiān)聽瀏覽器原生返回按鈕,進(jìn)行路由轉(zhuǎn)跳操作
這篇文章主要介紹了vue監(jiān)聽瀏覽器原生返回按鈕,進(jìn)行路由轉(zhuǎn)跳操作,具有很好的參考價(jià)值,希望對(duì)大家有所幫助。一起跟隨小編過來看看吧2020-09-09
vue百度地圖修改折線顏色,添加icon和文字標(biāo)注方式
這篇文章主要介紹了vue百度地圖修改折線顏色,添加icon和文字標(biāo)注方式,具有很好的參考價(jià)值,希望對(duì)大家有所幫助,如有錯(cuò)誤或未考慮完全的地方,望不吝賜教2024-03-03
在導(dǎo)入.vue文件的時(shí)候,ts報(bào)錯(cuò)提示:找不到模塊“@/Layout/index.vue”或其相應(yīng)的類型聲明問題
這篇文章主要介紹了在導(dǎo)入.vue文件的時(shí)候,ts報(bào)錯(cuò)提示:找不到模塊“@/Layout/index.vue”或其相應(yīng)的類型聲明問題,具有很好的參考價(jià)值,希望對(duì)大家有所幫助,如有錯(cuò)誤或未考慮完全的地方,望不吝賜教2024-08-08
Vue?Router?History路由刷新頁面404問題的原因分析和解決方法
在現(xiàn)代前端開發(fā)中,單頁面應(yīng)用憑借其流暢的用戶體驗(yàn)和高效的性能備受青睞,Vue?Router作為Vue.js官方的路由管理器,為構(gòu)建單頁面應(yīng)用提供了強(qiáng)大的路由功能,然而,使用History模式時(shí),刷新頁面出現(xiàn)404錯(cuò)誤,本文將深入探討該問題產(chǎn)生的原因,并提供詳細(xì)的解決方法2025-10-10
如何基于uniapp開發(fā)android播放webrtc流詳解
這篇文章主要介紹了在uniapp中播放RTSP和WebRTC協(xié)議流的區(qū)別,以及如何封裝WebrtcVideo組件和音視頻實(shí)時(shí)通訊的實(shí)現(xiàn),文中通過代碼介紹的非常詳細(xì),需要的朋友可以參考下2025-02-02
Vue3使用路由及配置vite.alias簡化導(dǎo)入寫法的過程詳解
這篇文章主要介紹了Vue3使用路由及配置vite.alias簡化導(dǎo)入寫法,本文通過實(shí)例代碼給大家講解的非常詳細(xì),對(duì)大家的學(xué)習(xí)或工作具有一定的參考借鑒價(jià)值,需要的朋友可以參考下2022-11-11
vue+echarts+datav大屏數(shù)據(jù)展示及實(shí)現(xiàn)中國地圖省市縣下鉆功能
這篇文章主要介紹了vue+echarts+datav大屏數(shù)據(jù)展示及實(shí)現(xiàn)中國地圖省市縣下鉆,本文通過實(shí)例代碼給大家介紹的非常詳細(xì),對(duì)大家的學(xué)習(xí)或工作具有一定的參考借鑒價(jià)值,需要的朋友可以參考下2020-11-11
vue為什么v-for的優(yōu)先級(jí)比v-if高原理解析
這篇文章主要為大家介紹了vue為什么v-for的優(yōu)先級(jí)比v-if高原理解析,有需要的朋友可以借鑒參考下,希望能夠有所幫助,祝大家多多進(jìn)步,早日升職加薪2023-05-05

