File tree 1 file changed +12
-10
lines changed
1 file changed +12
-10
lines changed Original file line number Diff line number Diff line change 535
535
}
536
536
537
537
this .curPage = parseInt (page, 10 );
538
- this .$emit (' page-change' , parseInt (page, 10 ) );
538
+ this .$emit (' page-change' , this . curPage );
539
539
540
- if (this .totalPage > 7 ) {
541
- this .getRenderPages ();
542
- }
540
+ this .getRenderPages ();
543
541
},
544
542
545
543
computedTotalPage () {
555
553
getRenderPages () {
556
554
const pages = [];
557
555
const middlePage = this .curPage ;
556
+ const restPage = this .totalPage - middlePage;
558
557
559
- let start = ( middlePage - this .pageDiff ) > 1 ? middlePage - this . pageDiff : 1 ;
560
- let end = ( middlePage + this .pageDiff ) < this . totalPage ? middlePage + this . pageDiff : this . totalPage ;
558
+ let start = middlePage - this .pageDiff ;
559
+ let end = middlePage + this .pageDiff ;
561
560
562
- start = (( this . totalPage - middlePage) < 3 && this . totalPage - middlePage >= 0 ) ? ( this .totalPage - 5 ) : start ;
563
- end = (end <= 6 && this .totalPage >= 6 ) ? 6 : end ;
561
+ if (restPage < 3 && restPage >= 0 ) start = this .totalPage - 5 ;
562
+ if (end <= 5 && this .totalPage >= 5 ) end = 5 ;
564
563
565
- start = start > 0 ? start : 1 ;
564
+ if (start < 1 ) start = 1 ;
565
+ if (end > this .totalPage ) end = this .totalPage ;
566
566
567
567
for (let i = start; i <= end; i++ ) {
568
568
pages .push ({
580
580
if (end !== this .totalPage ) {
581
581
pages .push ({
582
582
page: this .totalPage ,
583
- text: (this .totalPage - end > 1 && this .totalPage > 7 ) ? ` ...${ this .totalPage } ` : this .totalPage
583
+ text: (this .totalPage - end > 1 && this .totalPage > 6 )
584
+ ? ` ...${ this .totalPage } `
585
+ : this .totalPage
584
586
});
585
587
}
586
588
You can’t perform that action at this time.
0 commit comments