From 2d17618f4a26a6df83d358829707a9c251c88dac Mon Sep 17 00:00:00 2001 From: weibangtuo Date: Fri, 28 Jun 2024 19:47:07 +0800 Subject: [PATCH] avoid init twice when options and columns both changed --- src/vue/BootstrapTable.vue | 14 +++++++++++++- 1 file changed, 13 insertions(+), 1 deletion(-) diff --git a/src/vue/BootstrapTable.vue b/src/vue/BootstrapTable.vue index ddfd28334..0de40e101 100644 --- a/src/vue/BootstrapTable.vue +++ b/src/vue/BootstrapTable.vue @@ -31,6 +31,11 @@ export default { } } }, + data () { + return { + initTimer: 0 + } + }, mounted () { this.$table = $(this.$el) @@ -41,10 +46,17 @@ export default { this.$emit(eventName, ...args) }) - this._initTable() + this._doInitTable() }, methods: { _initTable () { + clearTimeout(this.initTimer) + // Avoid init too frequently + this.initTimer = setTimeout(() => { + this._doInitTable() + }, 20) + }, + _doInitTable () { const options = { ...deepCopy(this.options), columns: deepCopy(this.columns),