Skip to content

Commit e8a6f7c

Browse files
author
Kenneth Cheng
committed
revise $forceUpdate
1 parent 17c4721 commit e8a6f7c

File tree

3 files changed

+21
-15
lines changed

3 files changed

+21
-15
lines changed

package-lock.json

Lines changed: 1 addition & 1 deletion
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

package.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@
22
"name": "vue3-excel-editor",
33
"email": "apple.6502@gmail.com",
44
"description": "Vue3 plugin for displaying and editing the array-of-object in Excel style",
5-
"version": "1.0.17",
5+
"version": "1.0.18",
66
"main": "src/main.js",
77
"dependencies": {
88
"@vuepic/vue-datepicker": "^3.3.0",

src/VueExcelEditor.vue

Lines changed: 19 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -511,7 +511,8 @@ export default {
511511
})
512512
if (valid) {
513513
this.fields = newFields
514-
this.$forceUpdate()
514+
const instance = getCurrentInstance()
515+
instance?.proxy?.$forceUpdate()
515516
}
516517
}
517518
}
@@ -890,7 +891,8 @@ export default {
890891
else if (this.leftMost === -1) this.leftMost = left
891892
}
892893
})
893-
this.$forceUpdate()
894+
const instance = getCurrentInstance()
895+
instance?.proxy?.$forceUpdate()
894896
},
895897
renderColumnCellStyle (field) {
896898
let result = field.initStyle
@@ -1110,7 +1112,8 @@ export default {
11101112
this.vScroller.buttonHeight = Math.max(24, this.vScroller.height * ratio)
11111113
const prop = (this.tableContent.scrollTop + this.pageTop * 24) / (this.table.length * 24 - this.vScroller.height)
11121114
this.vScroller.buttonTop = (this.vScroller.height - this.vScroller.buttonHeight) * prop
1113-
this.$forceUpdate()
1115+
const instance = getCurrentInstance()
1116+
instance?.proxy?.$forceUpdate()
11141117
},
11151118
vsMouseDown (e) {
11161119
e.stopPropagation()
@@ -1149,7 +1152,8 @@ export default {
11491152
this.pageTop = Math.round((this.table.length - this.pageSize) * ratio)
11501153
}
11511154
this.vScroller.runner = ''
1152-
this.$forceUpdate()
1155+
const instance = getCurrentInstance()
1156+
instance?.proxy?.$forceUpdate()
11531157
},
11541158
vsbMouseMove (e) {
11551159
if (e.buttons === 0)
@@ -1171,7 +1175,8 @@ export default {
11711175
.filter((field, i) => field.keyField || field.sticky || this.sortPos === i)
11721176
.map(field => field.label + ': ' + rec[field.name])
11731177
.join('<br>')
1174-
this.$forceUpdate()
1178+
const instance = getCurrentInstance()
1179+
instance?.proxy?.$forceUpdate()
11751180
}
11761181
}
11771182
},
@@ -1198,14 +1203,15 @@ export default {
11981203
}
11991204
},
12001205
sbMouseUp () {
1201-
window.removeEventListener('mousemove', this.sbMouseMove)
1202-
window.removeEventListener('mouseup', this.sbMouseUp)
1203-
this.lazy(() => {
1204-
if (!this.$refs.hScroll) return
1205-
this.$refs.hScroll.classList.remove('focus')
1206-
})
1207-
this.hScroller.mouseX = 0
1208-
this.$forceUpdate()
1206+
window.removeEventListener('mousemove', this.sbMouseMove)
1207+
window.removeEventListener('mouseup', this.sbMouseUp)
1208+
this.lazy(() => {
1209+
if (!this.$refs.hScroll) return
1210+
this.$refs.hScroll.classList.remove('focus')
1211+
})
1212+
this.hScroller.mouseX = 0
1213+
const instance = getCurrentInstance()
1214+
instance?.proxy?.$forceUpdate()
12091215
},
12101216
sbMouseMove (e) {
12111217
if (e.buttons === 0)

0 commit comments

Comments
 (0)