原先用的是@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 内容,请继续关注编程基础学习网。
沃梦达教程
本文标题为:el-table 单项type="selection"出现数据错乱解决
猜你喜欢
- vue post application/x-www-form-urlencoded传参的解决方案 2023-10-08
- Vue常用指令v-if与v-show的区别浅析 2024-02-25
- js防止页面被iframe调用的方法 2024-01-16
- 微信小程序 页面跳转和数据传递实例详解 2023-12-24
- div三栏布局左中右通过float浮动来设置 2024-02-06
- 详解Html5 监听拦截Android返回键方法 2024-02-13
- 解析div与span区别与用法 2024-02-21
- js处理表格对table进行修饰 2024-02-06
- 微信小程序 生命周期和页面的生命周期详细介绍 2024-01-16
- javascript eval(func())使用示例 2024-01-17