获取SELECTION选中的数据
table绑定一列type为selection,绑定table中的@selection-change=“selectionLineChangeHandle”,每次点击触发事件,赋值给数组,最后提交时候遍历获取需要的值
table绑定@selection-change事件
1 2 3 4 5
| <el-table :data="dataonLineList" border @selection-change="selectionLineChangeHandle" style="width: 100%;">
|
1 2 3 4
| <el-table-column type="selection" width="55"> </el-table-column>
|
1
| dataonLineListSelections: [],
|
methods中添加事件
1 2 3
| selectionLineChangeHandle (val) { this.dataonLineListSelections = val },
|
提交时遍历列表,获取对应的数据id是你表格里面绑定的列
1 2 3 4 5 6 7
| fromCommit () { console.log(this.dataonLineListSelections); for(var i = 0; i< this.dataonLineListSelections.length; i++){ console.log('id:'+this.dataonLineListSelections[i].id) } }
|
相关链接(侵删)
- VUE中获取TABLE的SELECTION选中的数据
=================我是分割线=================
欢迎到公众号来唠嗑: