Skip to content

Commit 4c450ef

Browse files
Merge pull request lusaxweb#283 from brunokunace/feature/reactive_max_prop_table
added watch on max-items for reactive data
2 parents a94eb09 + 1ca0f8a commit 4c450ef

File tree

2 files changed

+15
-15
lines changed

2 files changed

+15
-15
lines changed

src/components/vsPagination/vsPagination.vue

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -106,6 +106,9 @@ export default {
106106
current() {
107107
this.getPages()
108108
this.$emit('input', this.current)
109+
},
110+
total() {
111+
this.getPages()
109112
}
110113
},
111114
@@ -137,7 +140,6 @@ export default {
137140
let pages = this.setPages(1, this.total)
138141
this.pages = pages
139142
}
140-
// console.log('this.total', this.total)
141143
const even = this.max % 2 === 0 ? 1 : 0
142144
if(this.total < 6) {
143145
this.prevRange = Math.floor(this.max / (this.max/2))

src/components/vsTable/vsTable.vue

Lines changed: 12 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -157,20 +157,15 @@ export default {
157157
},
158158
watch:{
159159
currentx() {
160-
let max = Math.ceil(this.currentx * this.maxItems)
161-
let min = max - this.maxItems
162-
163-
this.datax = this.getItems(min, max)
160+
this.loadData()
161+
},
162+
maxItems() {
163+
this.loadData()
164164
},
165165
data() {
166-
let max = Math.ceil(this.currentx * this.maxItems)
167-
let min = max - this.maxItems
168-
169-
let datax = this.pagination ? this.getItems(min, max) : this.data
170-
171-
this.datax = datax || []
166+
this.loadData()
172167
this.$nextTick(() => {
173-
if(datax.length > 0) {
168+
if(this.datax.length > 0) {
174169
this.changeTdsWidth()
175170
}
176171
})
@@ -182,10 +177,8 @@ export default {
182177
mounted () {
183178
window.addEventListener('resize', this.listenerChangeWidth)
184179
185-
let max = Math.ceil(this.currentx * this.maxItems)
186-
let min = max - this.maxItems
180+
this.loadData()
187181
188-
this.datax = this.pagination ? this.getItems(min, max) : this.data || []
189182
this.$nextTick(() => {
190183
if(this.datax.length > 0) {
191184
this.changeTdsWidth()
@@ -196,6 +189,11 @@ export default {
196189
window.removeEventListener('resize', this.listenerChangeWidth)
197190
},
198191
methods:{
192+
loadData() {
193+
let max = Math.ceil(this.currentx * this.maxItems)
194+
let min = max - this.maxItems
195+
this.datax = this.pagination ? this.getItems(min, max) : this.data || []
196+
},
199197
getItems(min, max) {
200198
let items = []
201199

0 commit comments

Comments
 (0)