作者 RuoYi

修复分页组件请求两次问题(I4SQOR)

1 <template> 1 <template>
2 <div :class="{'hidden':hidden}" class="pagination-container"> 2 <div :class="{'hidden':hidden}" class="pagination-container">
3 <el-pagination 3 <el-pagination
  4 + v-if="pageShow"
4 :background="background" 5 :background="background"
5 :current-page.sync="currentPage" 6 :current-page.sync="currentPage"
6 :page-size.sync="pageSize" 7 :page-size.sync="pageSize"
@@ -61,6 +62,11 @@ export default { @@ -61,6 +62,11 @@ export default {
61 default: false 62 default: false
62 } 63 }
63 }, 64 },
  65 + data() {
  66 + return {
  67 + pageShow: true
  68 + };
  69 + },
64 computed: { 70 computed: {
65 currentPage: { 71 currentPage: {
66 get() { 72 get() {
@@ -81,6 +87,12 @@ export default { @@ -81,6 +87,12 @@ export default {
81 }, 87 },
82 methods: { 88 methods: {
83 handleSizeChange(val) { 89 handleSizeChange(val) {
  90 + if (this.currentPage * val > this.total) {
  91 + this.pageShow = false;
  92 + this.$nextTick(() => {
  93 + this.pageShow = true
  94 + })
  95 + }
84 this.$emit('pagination', { page: this.currentPage, limit: val }) 96 this.$emit('pagination', { page: this.currentPage, limit: val })
85 if (this.autoScroll) { 97 if (this.autoScroll) {
86 scrollTo(0, 800) 98 scrollTo(0, 800)