項(xiàng)目中常見的分頁顯示,第二頁從1開始編號,然后在切換分頁的過程中,偶現(xiàn)不對,都是小問題,整理記錄一下,供參考。
template:
我們提供的服務(wù)有:成都網(wǎng)站設(shè)計(jì)、成都做網(wǎng)站、微信公眾號開發(fā)、網(wǎng)站優(yōu)化、網(wǎng)站認(rèn)證、鹽城ssl等。為上千企事業(yè)單位解決了網(wǎng)站和推廣的問題。提供周到的售前咨詢和貼心的售后服務(wù),是有科學(xué)管理、有技術(shù)的鹽城網(wǎng)站制作公司
... <el-table-column type="index" label="編號" :index="getIndex" width="80px"> </el-table-column> ... <Pagination :total="total" :pageSize="pageSize" :currentPage="currentPage" @sizeChange="sizeChange" @currentChange="currentChange"> </Pagination>
script:
getIndex (index) { if (this.currentPage==0){ return (this.currentPage) * this.pageSize + index + 1 } else{ return (this.currentPage-1) * this.pageSize + index + 1 } },
由于后端第一頁是從0開始的,而前端是從第一頁開始,所以需要在當(dāng)前頁減1。關(guān)于分頁,本頁條數(shù)
sizeChange(val){ let that = this; that.currentPage = 1; that.pageSize = val; that.getPageInfo(that.currentPage, val); },
跳轉(zhuǎn)頁面
currentChange(val){ let that = this; that.currentPage = val; that.getPageInfo(val, that.pageSize); },
頁面加載數(shù)據(jù)
getUserList(currentPage, pageSize){ let that = this; that.$axios({ method: 'get', url: '***', params: { currentPage: (currentPage || that.currentPage || 1)-1, pageSize: pageSize || that.pageSize || 10 }, needInterceptors: true, showError: true, loader: true }).then(function(result){ let data = result && result.data || []; let page = result && result.pageCont || {}; that.total = page.totalItems || 0; that.tableData = data; }) },
試了幾次,這樣寫應(yīng)該是沒有問題的,也解決了后端傳0開始的問題。
以上就是本文的全部內(nèi)容,希望對大家的學(xué)習(xí)有所幫助,也希望大家多多支持創(chuàng)新互聯(lián)。
本文題目:element表格翻頁第2頁從1開始編號(后端從0開始分頁)
當(dāng)前鏈接:http://chinadenli.net/article2/joijoc.html
成都網(wǎng)站建設(shè)公司_創(chuàng)新互聯(lián),為您提供品牌網(wǎng)站建設(shè)、品牌網(wǎng)站制作、網(wǎng)站維護(hù)、動(dòng)態(tài)網(wǎng)站、ChatGPT、網(wǎng)站導(dǎo)航
聲明:本網(wǎng)站發(fā)布的內(nèi)容(圖片、視頻和文字)以用戶投稿、用戶轉(zhuǎn)載內(nèi)容為主,如果涉及侵權(quán)請盡快告知,我們將會(huì)在第一時(shí)間刪除。文章觀點(diǎn)不代表本網(wǎng)站立場,如需處理請聯(lián)系客服。電話:028-86922220;郵箱:631063699@qq.com。內(nèi)容未經(jīng)允許不得轉(zhuǎn)載,或轉(zhuǎn)載時(shí)需注明來源: 創(chuàng)新互聯(lián)