请帮我写一个基于elementUI的表格分页
时间: 2023-03-29 22:03:47 浏览: 122
使用elementUI-table二次封装的表格带分页.rar
好的,我可以为您提供一个基于elementUI的表格分页的代码示例:
<template>
<div>
<el-table :data="tableData" style="width: 100%">
<el-table-column prop="name" label="姓名"></el-table-column>
<el-table-column prop="age" label="年龄"></el-table-column>
<el-table-column prop="address" label="地址"></el-table-column>
</el-table>
<el-pagination
@size-change="handleSizeChange"
@current-change="handleCurrentChange"
:current-page="currentPage"
:page-sizes="[10, 20, 30, 40]"
:page-size="pageSize"
layout="total, sizes, prev, pager, next, jumper"
:total="total">
</el-pagination>
</div>
</template>
<script>
export default {
data() {
return {
tableData: [
{ name: '张三', age: 18, address: '北京市海淀区' },
{ name: '李四', age: 25, address: '上海市浦东新区' },
{ name: '王五', age: 30, address: '广州市天河区' },
{ name: '赵六', age: 40, address: '深圳市南山区' },
{ name: '钱七', age: 50, address: '杭州市西湖区' }
],
currentPage: 1,
pageSize: 10,
total: 5
}
},
methods: {
handleSizeChange(val) {
this.pageSize = val
},
handleCurrentChange(val) {
this.currentPage = val
}
}
}
</script>
阅读全文