使用ele表格的header-dragend方法
// 拖动表头
headerDragend (newWidth, oldWidth, column, event) {
setTimeout(() => {
// console.log(newWidth)
// console.log('拖动表头改变列宽')
let applyTableColWidths = []
let applyTable = document.getElementById('applyTable')
console.log(applyTable)
let applyTableColgroup = applyTable.getElementsByTagName('colgroup')[0]
let applyTableCol = applyTableColgroup.getElementsByTagName('col')
for (var i = 0; i < applyTableCol.length - 1; i++) {
applyTableColWidths.push(applyTableCol[i].width)
}
let newArr = applyTableColWidths.slice(0, -1);
localStorage.setItem('applyTableColWidths', JSON.stringify(newArr))
}, 100)
},
//获取浏览器缓存的列宽 放在mounted里
getTableColWidth () {
let self = this
let tableWidth = localStorage.getItem('applyTableColWidths')
if (tableWidth) {
for (var item = 0; item < self.tableColumns.length; item++) {
self.tableColumns[item].width = JSON.parse(tableWidth)[item]
}
}
},