File tree Expand file tree Collapse file tree 1 file changed +20
-17
lines changed
Expand file tree Collapse file tree 1 file changed +20
-17
lines changed Original file line number Diff line number Diff line change 6868 sliceStart: 0
6969 }
7070 },
71- watch: {
72- value (value ) {
73- if (value > this .sliceStart + this .maxSize ) {
74- if (value > this .totalPage - this .maxSize ) {
75- this .sliceStart = this .totalPage - this .maxSize
76- } else {
77- this .sliceStart = value - 1
78- }
79- } else if (value < this .sliceStart + 1 ) {
80- if (value - this .maxSize > 0 ) {
81- this .sliceStart = value - this .maxSize
82- } else {
83- this .sliceStart = 0
84- }
85- }
86- }
87- },
8871 computed: {
8972 pageSize () {
9073 return this .size ? ` pagination-${ this .size } ` : ` `
10285 }
10386 },
10487 methods: {
88+ calculateSliceStart () {
89+ if (this .value > this .sliceStart + this .maxSize ) {
90+ if (this .value > this .totalPage - this .maxSize ) {
91+ this .sliceStart = this .totalPage - this .maxSize
92+ } else {
93+ this .sliceStart = this .value - 1
94+ }
95+ } else if (this .value < this .sliceStart + 1 ) {
96+ if (this .value - this .maxSize > 0 ) {
97+ this .sliceStart = this .value - this .maxSize
98+ } else {
99+ this .sliceStart = 0
100+ }
101+ }
102+ },
103+
105104 onPageChange (page ) {
106105 if (page > 0 && page <= this .totalPage ) {
107106 this .$emit (' input' , page)
118117 this .sliceStart = start
119118 }
120119 }
120+ },
121+ created () {
122+ this .calculateSliceStart ()
123+ this .$watch (vm => [vm .value , vm .maxSize , vm .totalPage ].join (), this .calculateSliceStart )
121124 }
122125 }
123126 </script >
You can’t perform that action at this time.
0 commit comments