Browse Source

Fixed virtual scroll cannot work bug in modal

zhixin 1 year ago
parent
commit
9a5ab23088

+ 2 - 2
src/extensions/cookie/bootstrap-table-cookie.js

@@ -506,12 +506,12 @@ $.BootstrapTable = class extends $.BootstrapTable {
     const bootstrapTable = this
     const cookies = {}
 
-    $.each(UtilsCookie.cookieIds, (key, value) => {
+    for (const [key, value] of Object.entries(UtilsCookie.cookieIds)) {
       cookies[key] = UtilsCookie.getCookie(bootstrapTable, value)
       if (key === 'columns' || key === 'hiddenColumns' || key === 'sortPriority') {
         cookies[key] = JSON.parse(cookies[key])
       }
-    })
+    }
     return cookies
   }
 

+ 2 - 2
src/extensions/i18n-enhance/bootstrap-table-i18n-enhance.js

@@ -9,8 +9,8 @@ $.fn.bootstrapTable.methods.push('changeLocale')
 $.BootstrapTable = class extends $.BootstrapTable {
 
   changeTitle (locale) {
-    $.each(this.options.columns, (idx, columnList) => {
-      $.each(columnList, (idx, column) => {
+    this.options.columns.forEach(columnList => {
+      columnList.forEach(column => {
         if (column.field) {
           column.title = locale[column.field]
         }

+ 3 - 1
src/virtual-scroll/index.js

@@ -37,6 +37,8 @@ class VirtualScroll {
       this.cache.scrollTop = this.scrollEl.scrollTop
       this.cache.data = this.contentEl.innerHTML = rows[0] + rows[0] + rows[0]
       this.getRowsHeight(rows)
+    } else if (this.blockHeight === 0) {
+      this.getRowsHeight(rows)
     }
 
     const data = this.initData(rows, this.getNum(fixedScroll))
@@ -67,7 +69,7 @@ class VirtualScroll {
   }
 
   getRowsHeight () {
-    if (typeof this.itemHeight === 'undefined') {
+    if (typeof this.itemHeight === 'undefined' || this.itemHeight === 0) {
       const nodes = this.contentEl.children
       const node = nodes[Math.floor(nodes.length / 2)]