admin管理员组文章数量:1362177
Im just wondering that there is no built-in functionality in the el-table ponent for pagination.
There is a seperate pagination ponent, but no explanation on how to use it bined with a el-table. I can't figure it out and im confused.
Could someone give a short and clear example how to bine them?
Im just wondering that there is no built-in functionality in the el-table ponent for pagination.
There is a seperate pagination ponent, but no explanation on how to use it bined with a el-table. I can't figure it out and im confused.
Could someone give a short and clear example how to bine them?
Share Improve this question asked Mar 28, 2020 at 14:49 configconfig 1461 gold badge1 silver badge10 bronze badges1 Answer
Reset to default 8I created a small example, in this case all data is already in the front-end, but in a real case scenario you probably doing a call to some back-end service, so if you want to apply stuff like sorting you have to do this yourself in the back-end service
Good luck with it.
HTML:
<script src="//unpkg./vue/dist/vue.js"></script>
<script src="//unpkg./[email protected]/lib/index.js"></script>
<div id="app">
<template>
<el-table :data="pagedTableData" style="width: 100%">
<el-table-column prop="date" label="Date" width="180"></el-table-column>
<el-table-column prop="name" label="Name" width="180"></el-table-column>
<el-table-column prop="address" label="Address"></el-table-column>
</el-table>
<el-pagination layout="prev, pager, next" :total="this.tableData.length" @current-change="setPage">
</el-pagination>
</template>
</div>
JS:
var Main = {
created() {
for (let i = 0; i < 100; i++) {
this.tableData.push({ date: '2016-05-03', name: 'Tom', address: `No. ${i}, Grove St, Los Angeles`
})
}
},
data() {
return {
tableData: [],
page: 1,
pageSize: 10
}
},
puted: {
pagedTableData() {
return this.tableData.slice(this.pageSize * this.page - this.pageSize, this.pageSize * this.page)
}
},
methods : {
setPage (val) {
this.page = val
}
}
}
var Ctor = Vue.extend(Main)
new Ctor().$mount('#app')
It is also available on Codepen
本文标签: javascriptHow to use pagination in a datatable in Element UIStack Overflow
版权声明:本文标题:javascript - How to use pagination in a datatable in Element UI? - Stack Overflow 内容由网友自发贡献,该文观点仅代表作者本人, 转载请联系作者并注明出处:http://www.betaflare.com/web/1743859346a2551446.html, 本站仅提供信息存储空间服务,不拥有所有权,不承担相关法律责任。如发现本站有涉嫌抄袭侵权/违法违规的内容,一经查实,本站将立刻删除。
发表评论