原先用的是@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"出现数据错乱解决
基础教程推荐
猜你喜欢
- javascript里模拟sleep(两种实现方式) 2023-11-30
- 使用HTML5中postMessage知识点解决Ajax中POST跨域问题 2022-10-17
- JavaScript编程中window的location与history对象详解 2023-12-26
- HTML:如何设置网页标题上的图标 2023-10-26
- js点击返回跳转到指定页面实现过程 2023-12-28
- HTML5视频播放标签video和音频播放标签audio标签的正确用法 2022-11-16
- 一个很酷的 Vue3 的请求库 2023-10-08
- CSS 实现绝对底部一个完美解决方案 2023-12-08
- jQuery.cookie.js使用方法及相关参数解释 2024-01-12
- Android应用开发中WebView的常用方法笔记整理 2024-03-08
