vue分页组件

vue分页组件_第1张图片

分页组件效果如上图,接下来直接上代码:

1、子组件Pagination.vue代码如下:

/**
 * 分页组件
 */




2、父组件引入Pagination组件

css

.pagination {
    font-size: $font-size-second;
    color: #999;
    letter-spacing: 1.8px;
    font-weight: 400;
    line-height: 40px;
    display: flex;
    margin-top: 50px;
    text-align: center;
    & > .pager {
        display: inline-block;
        white-space: nowrap;
    }
    .pn {
        float: left;
        cursor: pointer;
        width: 40px;
        height: 40px;
        line-height: 40px;
        margin-left: 24px;
        text-align: center;
        background: #F6F7FC;
        border-radius: 2px;
        font-family: PingFangSC-Regular;
        font-size: 18px;
        color: #999999;
        letter-spacing: 1.8px;
        font-weight: 400;
        outline: none;
        &:first-child {
            margin-left: 0;
        }
        &:hover:not(.disabled) {
            background-color: #3A5ECF;
            color: #fff;
        }
        &.active.active {
            background-color: #3A5ECF;
            border-color: #3A5ECF;
            color: #fff;
        }
        & > .dots {
            display: block;
            font-weight: bold;
            line-height: 30px;
            padding-bottom: 6px;
        }
        & > input {
            color: #666;
            border: 0;
            font-family: Arial, sans-serif;
            font-size: 15px;
            max-width: 40px;
            padding: 2px 1px;
        }
        &.prev, &.next {
            color: #999999;
            display: flex;
            align-items: center;
            justify-content: center;
        }
        &.prev{
            .arrow {
                width: 8px;
                height: 8px;
                display: block;
                margin-left: 4px;
                border-left: solid 1px currentColor;
                border-top: solid 1px currentColor;
                -webkit-transform: rotate(-45deg);
                transform: rotate(-45deg);
            }
        }
        &.next{
            .arrow {
                width: 8px;
                height: 8px;
                display: block;
                margin-right: 4px;
                border-bottom: solid 1px currentColor;
                border-right: solid 1px currentColor;
                -webkit-transform: rotate(-45deg);
                transform: rotate(-45deg);
            }
        }
        &.next,
        &.prev {
            color: #fff !important;
            background: #3A5ECF;
        }
        &.disabled {
            cursor: not-allowed;
            background: #F6F7FC;
            color: #999 !important;
        }
    }
    & > .elevator {
        display: inline-block;
        color: #888f9c;
        font-size: 14px;
        height: 40px;
        line-height: 40px;
        margin-left: 20px;
        position: relative;
        vertical-align: top;

        & > .pagenum {
            appearance: none;
            background: transparent;
            color: #666;
            border: 1px solid #E6E7EB;
            border-radius: 0;
            font-size: 18px;
            margin: 0 10px 0 2px;
            padding-left: 10px;
            width: 60px;
            height: 40px;
        }

        & > .icn {
            display: block;
            border-top: 6px solid #5C5C5C;
            border-left: 5px solid transparent;
            border-right: 5px solid transparent;
            border-bottom: none;
            pointer-events: none;
            position: absolute;
            top: 17px;
            left: 142px;
        }
    }
    .page-size{
        margin-left: 30px;
        display: flex;
        align-items: center;
        .page-select{
            height: 40px;
            background: #F6F7FC;
            min-width: 55px;
            padding: 0 8px;
            margin: 0 8px;
            border: none;
            outline: none;
            display: flex;
            align-items: center;
            justify-content: center;
            position: relative;
            cursor: pointer;
            &::after{
                content: '';
                width: 0px;
                display: block;
                height: 0px;  
                line-height: 0px;
                margin-left: 6px;
                border-top: 6px solid  #D8D8D8;
                border-left: 6px solid #F6F7FC;  
                border-right: 6px solid #F6F7FC;  
            }
            .select-box{
                position: absolute;
                left: 0;
                width: 100%;
                top: 40px;
                border: 1px solid #eee;
                .seleclt-opotion{
                    padding: 0 10px;
                    &:hover{
                        background: #F6F7FC;
                    }
                }
            }
        }
    }
}

你可能感兴趣的:(vue,vue.js)