當數據量過多時,使用分頁請求數據。
設置分頁的頁數自動回到第一頁。
例:
<div class="pagination"> <el-pagination background layout="prev, pager, next" :current-page.sync="currentPage" @current-change="current_change" :page-size="7" :total="total"> </el-pagination> </div> <script type="text/ecmascript-6"> export default { data(){ return{ currentPage: 1 } }, methods:{ backNumOne(){ this.currentPage = 1; } } } </script>
在使用elementUI組件的時候,遇到有選項卡在第一個選項卡點了分頁之后,換另一個選項卡,頁數應當自動返回第一頁,但是並沒有自動返回,所以需要手動設置一下。el-pagination內增加 :current-page.sync 屬性(粉色字體屬性),該屬性指的就是 當前頁數。
此方法 也可以 做回顯頁面時設置 存儲的頁面數。