当前位置:   article > 正文

el-table设置只能单选_el-table只能单选

el-table只能单选
  1. <el-table
  2. ref="videoList"
  3. :data="list"
  4. border
  5. style="width: 100%"
  6. @selection-change="setSelectRows"
  7. >
  8. <el-table-column type="selection" width="50"></el-table-column>
  9. </el-table>
  10. export default {
  11. data() {
  12. return {
  13. list: [],
  14. selectRows:[],
  15. }
  16. },
  17. methods: {
  18. //表格只能单选
  19. setSelectRows(selection) {
  20. this.selectRows = []
  21. if (selection.length > 1) {
  22. this.$refs.videoList.clearSelection()
  23. this.$refs.videoList.toggleRowSelection(
  24. selection[selection.length - 1]
  25. )
  26. }
  27. this.selectRows = [selection[selection.length - 1]]
  28. },
  29. }

声明:本文内容由网友自发贡献,不代表【wpsshop博客】立场,版权归原作者所有,本站不承担相应法律责任。如您发现有侵权的内容,请联系我们。转载请注明出处:https://www.wpsshop.cn/w/码创造者/article/detail/770977
推荐阅读