小编Mih*_*vic的帖子

如何防止 Bootstrap-Vue 分页自动重置

我有多个视图,我想保存每个视图的状态,这样用户就不必再次执行相同的操作。

在其中一个上,我有一个表,并使用引导分页组件进行分页,因此当用户更改页面时,我将请求发送到服务器以获取新数据。我在 Vuex 中存储排序和过滤参数,效果很好。

但是当我想像这样保存当前页面时,每次更改视图并返回时,bootstrap-pagination 都会将其更改为 1。是否可以阻止这种行为?

以下是 HTML 代码:

<b-pagination v-if="currentPage!=-1"
            v-model="currentPage"
            :total-rows="totalRows"
            :per-page="perPage"
            aria-controls="my-table"
            pils
            align="center"
            class="ml-auto mr-auto"
          ></b-pagination>
Run Code Online (Sandbox Code Playgroud)

和 JavaScript 代码:

  data: function () {
      return {
        ...
        currentPage: this.$store.state.currentPage,
        ...
      }
    },

    ...

    watch: {
        currentPage: function(){
                this.$store.commit('updateCurrentPage', this.currentPage);
                this.getData();
              },
    }
Run Code Online (Sandbox Code Playgroud)

vue.js vuex bootstrap-vue

2
推荐指数
1
解决办法
1780
查看次数

标签 统计

bootstrap-vue ×1

vue.js ×1

vuex ×1