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)文章
vue實(shí)現(xiàn)多級(jí)側(cè)邊欄的封裝
這篇文章主要為大家詳細(xì)介紹了vue實(shí)現(xiàn)多級(jí)側(cè)邊欄的封裝,文中示例代碼介紹的非常詳細(xì),具有一定的參考價(jià)值,感興趣的小伙伴們可以參考一下2022-07-07vue上傳文件formData入?yún)榭?接口請(qǐng)求500的解決
這篇文章主要介紹了vue上傳文件formData入?yún)榭?接口請(qǐng)求500的解決,具有很好的參考價(jià)值,希望對(duì)大家有所幫助。如有錯(cuò)誤或未考慮完全的地方,望不吝賜教2022-06-06vue+element實(shí)現(xiàn)輸入密碼鎖屏
這篇文章主要為大家詳細(xì)介紹了vue+element實(shí)現(xiàn)輸入密碼鎖屏,文中示例代碼介紹的非常詳細(xì),具有一定的參考價(jià)值,感興趣的小伙伴們可以參考一下2022-03-03ant design中upload組件上傳大文件,顯示進(jìn)度條進(jìn)度的實(shí)例
這篇文章主要介紹了ant design中upload組件上傳大文件,顯示進(jìn)度條進(jìn)度的實(shí)例,具有很好的參考價(jià)值,希望對(duì)大家有所幫助。一起跟隨小編過(guò)來(lái)看看吧2020-10-10Vue3+ts+setup?getCurrentInstance使用時(shí)遇到的問(wèn)題以及解決辦法
getCurrentInstance方法用于獲取當(dāng)前組件實(shí)例,僅在setup和生命周期中起作用,下面這篇文章主要給大家介紹了關(guān)于Vue3+ts+setup?getCurrentInstance使用時(shí)遇到的問(wèn)題以及解決辦法,需要的朋友可以參考下2022-08-08