解决一个iview table组件报错问题You may have an infinite update loop in watcher with expression "columns"
问题如下
组件如下
data数据如下
这是因为iview 的table 组件不支持 双表头
我在网上搜了一遍,看见大佬改了ivew 的源码(666)
将view.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
},
这样错误解决了。
但是我们大佬不让改源码
但是他又说我们可以改为单表头的((*^_^*))