在工作过程中,经常会用到table表格用于数据的展示,对应的数据过多时,则需要用到分页器。

elementUi中已经有了很多分页器的样式,完全可以满足正常的使用需求。
在这里插入图片描述
如果想要实现下方的分页器的样式,则需要改动样式及部分功能:
在这里插入图片描述
首先可以看到想要的效果图中,跟elementUi中红框标注的样式很类似。
区别在于:

  1. 页码的背景颜色及边框
  2. 上页 下页将图标改为文字
  3. 添加首页 尾页

html部分代码如下:

<div class="page">
    <div class="homePage" v-on:click="homePageFn">首页</div>
    <el-pagination prev-text="上页" next-text="下页"
                   v-on:current-change="handleCurrentChange"
                   :current-page="searchInfo.PageIndex"
                   :page-size="searchInfo.PageSize"
                   layout="prev, pager, next"
                   :total="TotalCount">
    </el-pagination>
    <div class="lastPage" v-on:click="lastPageFn">尾页</div>
</div>
element
A Vue.js 2.0 UI Toolkit for Web

css样式部分代码如下:

 .page {
    display: flex;
    justify-content: center;
    align-items: center;
    font-size: 13px;
    color: #656565;
    margin-top: 20px;
    padding-bottom: 20px;
}

.page > div.homePage, .page > div.lastPage {
    height: 34px;
    line-height: 34px;
    width: 50px;
    text-align: center;
    border: 1px solid #EAEAEA;
    box-sizing: border-box;
    cursor: pointer;
}

.page > div.homePage {
    border-right: none;
    border-radius: 2px 0 0 2px;
}

.page > div.lastPage {
    border-left: none;
    border-radius: 0 2px 2px 0;
}

.el-pagination {
    text-align: center;
    padding: 0;
}

.el-pagination > button {
    padding: 0 !important;
    height: 34px !important;
}

.el-pagination > button.btn-prev {
    border-right: none !important;
}

 .el-pagination span {
     color: #656565;
     width: 50px;
     border: 1px solid #EAEAEA;
     height: 34px !important;
     line-height: 34px !important;
     box-sizing: border-box;
 }

 .el-pagination .el-pager .number, .el-icon.more.el-icon-more {
     color: #656565 !important;
     border: 1px solid #EAEAEA;
     height: 34px !important;
     line-height: 34px !important;
     box-sizing: border-box;
 }

.el-icon.more.btn-quicknext.el-icon-more {
    border-right: none;
}

.el-icon.more.btn-quickprev.el-icon-more {
    border-left: none;
}

.el-pagination .el-pager .number:not(:first-child) {
    border-right: none !important;
}

.el-pagination .el-pager .number.active {
    background: #FF9900;
    border: 1px solid #FF9900;
    color: #FFFFFF !important;
}

js部分代码如下:

homePageFn() {
    if (this.searchInfo.PageIndex == 1) {
        return;
    }
    this.searchInfo.PageIndex = 1;
    //this.getList();   调取列表数据
},
lastPageFn() {
    var lastPage = Math.ceil(this.TotalCount / this.searchInfo.PageSize);
    if (this.searchInfo.PageIndex == lastPage) {
        return;
    }
    this.searchInfo.PageIndex = lastPage;
    //this.getList();调取列表数据
},
阅读全文
AI总结
GitHub 加速计划 / eleme / element
10
1
下载
A Vue.js 2.0 UI Toolkit for Web
最近提交(Master分支:7 个月前 )
c345bb45 11 个月前
a07f3a59 * Update transition.md * Update table.md * Update transition.md * Update table.md * Update transition.md * Update table.md * Update table.md * Update transition.md * Update popover.md 11 个月前
Logo

旨在为数千万中国开发者提供一个无缝且高效的云端环境,以支持学习、使用和贡献开源项目。

更多推荐