這篇文章主要為大家展示了“vue如何基于element-ui分頁組件封裝”,內(nèi)容簡而易懂,條理清晰,希望能夠幫助大家解決疑惑,下面讓小編帶領(lǐng)大家一起研究并學習一下“vue如何基于element-ui分頁組件封裝”這篇文章吧。

創(chuàng)新互聯(lián)建站是一家專注于網(wǎng)站設(shè)計、網(wǎng)站制作和成都服務(wù)器托管的網(wǎng)絡(luò)公司,有著豐富的建站經(jīng)驗和案例。
具體代碼如下所示:
<template>
<el-pagination @size-change="handleSizeChange" @current-change="handleCurrentChange" :page-sizes="[10, 20, 30, 40]" :page-size="pageSize" layout="total, sizes, prev, pager, next, jumper" :total="total" >
</el-pagination>
</template>
<script type="text/ecmascript-6">
export default {
components: {
},
data() {
return {
}
},
props: {
pageSize: {
type: Number,
default: 10
},
total: {
type: Number,
default: 1
}
},
watch: {
},
methods: {
//每頁展示條數(shù)
handleSizeChange(val) {
//事件傳遞
this.$emit('handleSizeChangeSub', val);
},
//當前頁
handleCurrentChange(val) {
//事件傳遞
this.$emit('handleCurrentChangeSub', val);
}
},
// 過濾器設(shè)計目的就是用于簡單的文本轉(zhuǎn)換
filters: {},
// 若要實現(xiàn)更復(fù)雜的數(shù)據(jù)變換,你應(yīng)該使用計算屬性
computed: {
},
created() {
},
mounted() {},
destroyed() {}
}
</script>
<style lang="scss" type="text/css" scoped>
</style>調(diào)用
// 分頁
import pages from 'components/common/pages/pages'
components: {
pages
},
<pages :total="total" :page-size="pageSize" @handleSizeChangeSub="handleSizeChangeFun" @handleCurrentChangeSub="handleCurrentChangeFun"></pages>
handleSizeChangeFun(v) {
this.pageSize = v;
this._enterpriseList(); //更新列表
},
handleCurrentChangeFun(v) { //頁面點擊
this.pageNum = v; //當前頁
this._enterpriseList(); //更新列表
}補充:下面看下Element-ui組件--pagination分頁
一般寫后臺系統(tǒng)都會有很多的列表,有列表就相應(yīng)的要用到分頁,根據(jù)項目中寫的幾個分頁寫一下我對分頁的理解,就當是學習筆記了。
這是Element-ui提供的完整的例子
<template> <div class="block">
<el-pagination
@size-change="handleSizeChange"
@current-change="handleCurrentChange"
:current-page="currentPage"
:page-sizes="[100, 200, 300, 400]"//這事下拉框可以選擇的,選擇一夜顯示幾條數(shù)據(jù)
:page-size="100" //這是當前煤業(yè)顯示的條數(shù)
layout="total, sizes, prev, pager, next, jumper"
:total="400" //這個是總共有多少條數(shù)據(jù),把后臺獲取到的數(shù)據(jù)總數(shù)復(fù)制給total就可以了
>
</el-pagination>
</div>
</template>
<script>
export default {
methods: {
handleSizeChange(val) {
console.log(`每頁 ${val} 條`);
},
handleCurrentChange(val) {
console.log(`當前頁: ${val}`);
}
},
data() {
return {
total:'0',
currentPage: 4
};
}
}
</script>以下是我自己在項目中用到的分頁
<div > <el-pagination @size-change="handleSizeChange" @current-change="handleCurrentChange" :current-page="currentPage4" :page-sizes="[5, 10, 20, 30]" :page-size="pageSize" //寫代碼時忘記把pageSize賦值給:page-size了, layout="total, sizes, prev, pager, next, jumper" :total="totalCount"> </el-pagination> </div>
以上是“vue如何基于element-ui分頁組件封裝”這篇文章的所有內(nèi)容,感謝各位的閱讀!相信大家都有了一定的了解,希望分享的內(nèi)容對大家有所幫助,如果還想學習更多知識,歡迎關(guān)注創(chuàng)新互聯(lián)行業(yè)資訊頻道!
網(wǎng)站標題:vue如何基于element-ui分頁組件封裝
網(wǎng)站鏈接:http://chinadenli.net/article18/ggjidp.html
成都網(wǎng)站建設(shè)公司_創(chuàng)新互聯(lián),為您提供、外貿(mào)建站、App開發(fā)、網(wǎng)站設(shè)計、靜態(tài)網(wǎng)站、面包屑導(dǎo)航
聲明:本網(wǎng)站發(fā)布的內(nèi)容(圖片、視頻和文字)以用戶投稿、用戶轉(zhuǎn)載內(nèi)容為主,如果涉及侵權(quán)請盡快告知,我們將會在第一時間刪除。文章觀點不代表本網(wǎng)站立場,如需處理請聯(lián)系客服。電話:028-86922220;郵箱:631063699@qq.com。內(nèi)容未經(jīng)允許不得轉(zhuǎn)載,或轉(zhuǎn)載時需注明來源: 創(chuàng)新互聯(lián)