解决iview多表头动态更改列元素发生的错误的方法

这篇文章主要介绍了解决iview多表头动态更改列元素发生的错误的方法,小编觉得挺不错的,现在分享给大家,也给大家做个参考。一起跟随小编过来看看吧

解决iview 'You may have an infinite update loop in watcher with expression "columns"'

解决方案

单表头是可以动态变化不需要增添什么东西

多表头目前iview尚不能动态变化,会报错You may have an infinite update loop in watcher with expression "columns"解决方法是github大神提供的:需要修改iview.js源码

将iview.js中

 columns: { handler: function handler() { var colsWithId = this.makeColumnsId(this.columns); his.allColumns = (0, _util.getAllColumns)(colsWithId); this.cloneColumns = this.makeColumns(colsWithId); this.columnRows = this.makeColumnRows(false, colsWithId); this.leftFixedColumnRows = this.makeColumnRows('left', colsWithId); this.rightFixedColumnRows = this.makeColumnRows('right', colsWithId); this.rebuildData = this.makeDataWithSortAndFilter(); this.handleResize(); }, deep: true },

修改为

 columns: { handler: function handler() { //[Fix Bug]You may have an infinite update loop in watcher with expression "columns" var tempClonedColumns = (0, _assist.deepCopy)(this.columns); var colsWithId = this.makeColumnsId(tempClonedColumns); //[Fix Bug End] this.allColumns = (0, _util.getAllColumns)(colsWithId); this.cloneColumns = this.makeColumns(colsWithId); this.columnRows = this.makeColumnRows(false, colsWithId); this.leftFixedColumnRows = this.makeColumnRows('left', colsWithId); this.rightFixedColumnRows = this.makeColumnRows('right', colsWithId); this.rebuildData = this.makeDataWithSortAndFilter(); this.handleResize(); }, deep: true },

demo

 

以上就是解决iview多表头动态更改列元素发生的错误的方法的详细内容,更多请关注0133技术站其它相关文章!

赞(0) 打赏
未经允许不得转载:0133技术站首页 » Vue.js 教程