el-pagenation 组件 删除时候的 页码减一

如果删除数量的等于当前页数量的时候 并且当前页大于1 则当前页减1 子组件内的currentpage也减1

if   (  arr.length == this.tableData1.length && this.fatherCurrentPage1 > 1){
this.fatherCurrentPage1 = this.fatherCurrentPage1 - 1
this.$refs.pagenation1.currentPage=this.fatherCurrentPage1
}

  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 1
    评论
当然可以,以下是一个手写的Vue 2的el-pagination组件的示例代码: ```html <template> <div class="el-pagination"> <button @click="prevPage">Previous</button> <ul> <li v-for="page in pageCount" :key="page" :class="{ active: currentPage === page }"> <a @click="changePage(page)">{{ page }}</a> </li> </ul> <button @click="nextPage">Next</button> </div> </template> <script> export default { data() { return { currentPage: 1, pageSize: 10, total: 100 }; }, computed: { pageCount() { return Math.ceil(this.total / this.pageSize); } }, methods: { changePage(page) { this.currentPage = page; // 触发页码改变的事件,可以在父组件监听该事件并更新数据 this.$emit('page-change', page); }, prevPage() { if (this.currentPage > 1) { this.changePage(this.currentPage - 1); } }, nextPage() { if (this.currentPage < this.pageCount) { this.changePage(this.currentPage + 1); } } } }; </script> <style scoped> .el-pagination { display: flex; justify-content: center; align-items: center; } .el-pagination button { margin: 0 5px; } .el-pagination ul { list-style: none; display: flex; } .el-pagination li { margin: 0 5px; } .el-pagination li a { text-decoration: none; color: #333; padding: 5px; } .el-pagination li.active a { font-weight: bold; } </style> ``` 这是一个简单的分页组件,包含了上一页、下一页按钮以及页码列表。你可以根据需要进行样式的修改和功能的扩展。希望能帮到你!如果还有其他问题,请继续提问。

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论 1
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值