最新国产好看的视频,伊人天堂AV在线,国产Aaaaaa视频,蜜臀视频在线观看一区,人妻av色图,密臀久久久精品影片,青青视频免费观看毛片,久草在线观看视,国产三级精品色情在线

vue如何使用element-ui 實(shí)現(xiàn)自定義分頁(yè)

 更新時(shí)間:2024年07月19日 10:03:16   作者:小瓶子  
這篇文章主要介紹了vue如何使用element-ui 實(shí)現(xiàn)自定義分頁(yè),可以通過插槽實(shí)現(xiàn)自定義的分頁(yè),本文通過實(shí)例圖文相結(jié)合給大家介紹的非常詳細(xì),感興趣的朋友一起看看吧

element-ui文檔截圖,plus大同小異。

可以通過插槽實(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)文章希望大家以后多多支持腳本之家!

相關(guān)文章

最新評(píng)論

永安市| 鄂尔多斯市| 安陆市| 石狮市| 柳州市| 长葛市| 绍兴县| 井研县| 若羌县| 庐江县| 新巴尔虎左旗| 芦溪县| 奎屯市| 方正县| 五莲县| 确山县| 逊克县| 西昌市| 铜梁县| 宁德市| 东方市| 鹤壁市| 渭源县| 屯昌县| 绵阳市| 三门县| 天峻县| 玉林市| 贞丰县| 黑河市| 十堰市| 临泽县| 武陟县| 昌宁县| 宁城县| 泰州市| 耒阳市| 普兰县| 新泰市| 托克逊县| 托克托县|