el-table 单项type="selection"出现数据错乱解决
原先用的是@selection-change="selectionLineChangeHandle",发现会出现数据错乱,选中下一条获取的数据还是上一条。解决方法如下:
template代码
//把下面语句
el-table @selection-change="selectionLineChangeHandle" ref="table"
//改成
el-table @select="(selection, row) => {selectionLineChangeHandle(selection, row);}" ref="table"
js代码
//选中事件
selectionLineChangeHandle(selection, val) {
// 单选
this.dataonLineListSelections = [];
if (selection.length > 1) {
this.$refs.table.clearSelection();
this.$refs.table.toggleRowSelection(selection.pop());
}
if (selection.length > 0) {
this.dataonLineListSelections.push(val);
}
}
在列表接口中清空dataonLineListSelections
以上是编程学习网小编为您介绍的“el-table 单项type="selection"出现数据错乱解决”的全面内容,想了解更多关于 vuejs 内容,请继续关注编程基础学习网。