vue如何使用element-ui 實(shí)現(xiàn)自定義分頁(yè)
element-ui文檔截圖,plus大同小異。

可以通過(guò)插槽實(shí)現(xiàn)自定義的分頁(yè)。在layout里面進(jìn)行配置。

全部代碼
//page.js
export default {
name:Cuspage,
props:{
total:Number,
},
data(){
return {
currentPage:1,
pageSize:10,
}
}
methods: {
setslot (h) {
return(
<div class="cusPage"?
<span on-click={this.toBegin}>首頁(yè)く/span>
<span on-click={this.toPre}>上一頁(yè)く/Span>
<span on-click={this.tovext}>下一頁(yè)</span>
<span on-click={this.toEnd}>未頁(yè)く/span>
<span>
第{this.currentPage}/{this.alltotal}頁(yè)
</span>
</div>
)
},
toEnd(){
this.$emit('current-change',this.allPage);
this.currentPage = this.allPage;
},
toBegin() {
this.$emit('current-change',1);
this.currentPage = 1;
}
toNext() {
if(this.$refs.cusPage){
this.$refs.cusPage.next()
}
},
toPre() {
if(this.$refs.cusPage){
this.$refs.cusPage.prev()
}
},
currentChange(val) {
this.currenPage = val;
this.$emit('current-change',val);
},
sizeChange (val) {
this.pageSize= val;
this.$emit('size-change',val);
}
},
computed:{
//計(jì)算出當(dāng)前的總頁(yè)數(shù)
allPage() {
return Math.max(1,Math.ceil(Number(this.total)/Number(this.pageSize))
}
},
render (h) {
const pageprops =
props: {
layout: 'total, slot,sizes, prev, pager,'
pagesize: this-pagesize,
currentPage: this.currentPage,
total: 100,
}
}
return (
<el-pagination
class="page-custome"
{...pageprops}
ref-"cusPage"
onCurrent-change={(v)=>{this.currentChange(v)}}
onSize-change={(v)=>{this.sizeChange (v)}}
onPrev-click={(v) =>{this.PrevChange (v)}}
onNext-change={(v)=>{this.NextChange (v)}}
<template slot="default">
{this.setslot(h)}
</template>
</el-pagination>
)
}
}組件內(nèi)使用
<cus-page :total="100" @current-change="currentChange" ...></cus-page>
實(shí)現(xiàn)效果圖

里面具體的邏輯可以自己實(shí)現(xiàn)下。
到此這篇關(guān)于vue使用element-ui 實(shí)現(xiàn)自定義分頁(yè)的文章就介紹到這了,更多相關(guān)vue element-ui 分頁(yè)內(nèi)容請(qǐng)搜索腳本之家以前的文章或繼續(xù)瀏覽下面的相關(guān)文章希望大家以后多多支持腳本之家!
- Vue使用Element-UI實(shí)現(xiàn)分頁(yè)效果全過(guò)程
- 利用Vue模擬實(shí)現(xiàn)element-ui的分頁(yè)器效果
- vue+Element-ui前端實(shí)現(xiàn)分頁(yè)效果
- vue+Element-ui實(shí)現(xiàn)分頁(yè)效果
- 在vue和element-ui的table中實(shí)現(xiàn)分頁(yè)復(fù)選功能
- vue + element-ui的分頁(yè)問(wèn)題實(shí)現(xiàn)
- vue+Element-ui實(shí)現(xiàn)分頁(yè)效果實(shí)例代碼詳解
- vue 基于element-ui 分頁(yè)組件封裝的實(shí)例代碼
- Vue+element-ui 實(shí)現(xiàn)表格的分頁(yè)功能示例
- 利用vue和element-ui設(shè)置表格內(nèi)容分頁(yè)的實(shí)例
相關(guān)文章
vue3+elementPlus項(xiàng)目支持設(shè)置默認(rèn)附件方式
這篇文章主要介紹了vue3+elementPlus項(xiàng)目支持設(shè)置默認(rèn)附件方式,具有很好的參考價(jià)值,希望對(duì)大家有所幫助,如有錯(cuò)誤或未考慮完全的地方,望不吝賜教2024-03-03
Vuex模塊化和命名空間namespaced實(shí)例演示
這篇文章主要介紹了Vuex模塊化和命名空間namespaced的相關(guān)知識(shí),本文通過(guò)實(shí)例代碼給大家介紹的非常詳細(xì),對(duì)大家的學(xué)習(xí)或工作具有一定的參考借鑒價(jià)值,需要的朋友可以參考下2021-11-11
Uniapp打包Android文件選擇上傳問(wèn)題圖文詳解
在移動(dòng)應(yīng)用開(kāi)發(fā)中,文件上傳是一項(xiàng)常見(jiàn)的功能,尤其在社交、云存儲(chǔ)以及各種服務(wù)類應(yīng)用中,這篇文章主要介紹了Uniapp打包Android文件選擇上傳問(wèn)題的相關(guān)資料,需要的朋友可以參考下2025-06-06
vue中內(nèi)嵌iframe的src更新頁(yè)面未刷新問(wèn)題及解決
這篇文章主要介紹了vue中內(nèi)嵌iframe的src更新頁(yè)面未刷新問(wèn)題及解決方案,具有很好的參考價(jià)值,希望對(duì)大家有所幫助。如有錯(cuò)誤或未考慮完全的地方,望不吝賜教2022-12-12
Vue3實(shí)現(xiàn)地圖選點(diǎn)組件的示例代碼
這篇文章主要為大家詳細(xì)介紹了Vue3實(shí)現(xiàn)地圖選點(diǎn)組件的相關(guān)知識(shí),文中的示例代碼講解詳細(xì),感興趣的小伙伴可以跟隨小編一起學(xué)習(xí)一下2024-01-01
vue2.0實(shí)現(xiàn)前端星星評(píng)分功能組件實(shí)例代碼
本文通過(guò)實(shí)例代碼給大家介紹了vue2.0實(shí)現(xiàn)前端星星評(píng)分功能組件,非常不錯(cuò),具有參考借鑒價(jià)值,需要的朋友參考下吧2018-02-02
vue踩坑記錄之src的動(dòng)態(tài)綁定賦值問(wèn)題
這篇文章主要介紹了vue踩坑記錄之src的動(dòng)態(tài)綁定賦值問(wèn)題,具有很好的參考價(jià)值,希望對(duì)大家有所幫助。如有錯(cuò)誤或未考慮完全的地方,望不吝賜教2023-06-06

