el-pagination 本地存储再更新当前页码

2020-03-24 10:57:17 浏览数 (1)

通过定时器触发更新

代码语言:javascript复制
  mounted() {
    // 更新当前页码
    let page = Number(localStorage.getItem("saPage")) || 1;
    this.$nextTick(function() {
      this.change(page);
    });
    console.log(this.currentPage2);
  },
  // 触发更新
    change(page) {
      // 模拟数据返回
      setTimeout(() => {
        this.currentPage2 = page; // 再次赋值
      }, 1000);
    }


        <el-pagination
              ref="pagination"
             
              background
              layout="prev, pager, next"
              :total="total"
              :current-page.sync="currentPage2"
              @current-change="changePage"
            ></el-pagination>

0 人点赞