通过定时器触发更新
代码语言: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>