element-ui el-table,查询数据后默认返回第一页数据

 

一 场景

场景是默认数据有30页, 这个时候你切换到30页,再次加搜索条件查询你的currentPage会变为当前数据最后一页,但是查询字段还是30页

二 解决办法

我会在confirm查询时候将页数调回到第一页, 同时监听page分页组件中的currenpage回到第一页,

这一步完成查询数据是第一页的数据

queryData(query) {
      this.query = query
      this.pageChange(1)
      this.getList()
    },
    pageChange(val) {
      this.currentPage = val
      this.getList()
    },

 这一步将page分页组件中的currentpage页设置为第一页

watch: {
    currentPage: {
      handler() {
        this.current = this.currentPage
      },
      deep: true,
    },
  },

解决

加油加油

猜你喜欢

转载自blog.csdn.net/sunnyboysix/article/details/111287437