<p>可以在pagination组件的@pagination事件中调用getList方法来获取分页数据,然后在handleQuery方法中添加this.queryParams.pageNo = 1来重置页码,这样每次搜索时就会从第一页开始显示数据。具体代码如下:</p>
<template>
  <!-- ... -->
  <!-- 分页组件 -->
  <pagination
      v-show="total > 0"
      :total="total"
      :page.sync="queryParams.pageNo"
      :limit.sync="queryParams.pageSize"
      @pagination="getList"
  />
</template>
<script>
export default {
  // ...
  methods: {
    // ...
    /** 搜索按钮操作 */
    handleQuery() {
      this.queryParams.pageNo = 1 // 重置页码为1
      this.getList()
    },
    /** 分页操作 */
    getList() {
      this.loading = true
      // 执行查询
      getDiversionStatsPage(this.queryParams).then((response) => {
        this.list = response.data.list
        this.total = response.data.total
        this.loading = false
      })
    },
    // ...
  },
}
</script>
vue如何点击搜索按钮切换分页组件template div class=app-container div class=app-container-search main-bgcolor main-radius h1 class=窜货统计h1 br !-- 搜索工作栏 -- StatsForm searchFormParam= qu

原文地址: https://www.cveoy.top/t/topic/0r1 著作权归作者所有。请勿转载和采集!

免费AI点我,无需注册和登录