1. 程式人生 > 其它 >elementui中 分頁在vue中的使用

elementui中 分頁在vue中的使用

template中:

 <el-pagination background layout="prev, pager, next" 
    :total="total"
    :page-size ="per_page"
    :current-page="currentPage"
    @current-change="current_change"
 ></el-pagination>

script中:

 data(){
        return {
            total:0,  //總條數
            currentPage:1,  //當前頁
            per_page: 
0, //每頁幾條資料 } }, // 分頁 current_change(currentPage){ //改變當前頁 this.currentPage = currentPage; this.init(this.currentPage) //請求的介面傳入分頁 },

另外:改變分頁的按鈕顏色和大小的方法

>>>.el-pager li{
  width: 36px;
  height: 36px;
  line-height: 36px;
}
>>>.el-pagination.is-background .el-pager li:not(.disabled).active{
  background
-color: #0C9F9A!important; width: 36px; height: 36px; line-height: 36px; } /* .el-pager */ >>>.el-pagination.is-background .btn-next, .el-pagination.is-background .btn-prev, .el-pagination.is-background .el-pager li{ height: 36px; min-width: 36px; } >>>.el-pagination.is-background .btn-prev, .el-pagination.is
-background .btn-prev, .el-pagination.is-background .el-pager li{ height: 36px; min-width: 36px; }