zoukankan      html  css  js  c++  java
  • element table 复选框单选

    前段html代码

    <el-table :data="tableData"
                                      height="350"
                                      border
                                      stripe
                                      @@selection-change="handleSelectionChange"
                                      ref="multipleTable">
                                <el-table-column type="selection"
                                                  width="40"
                                                 resizable>
                                </el-table-column>
                                
                                <el-table-column 
                                                 resizable
                                                 prop="CNFiledName"
                                                 label="ColumnName"
                                                 >
                                </el-table-column>
                            </el-table>

    后台js代码

       handleSelectionChange(val) {
                
                if (val.length == 2) {
                    this.$refs.multipleTable.clearSelection(); //清空列表的选中
                    this.$refs.multipleTable.toggleRowSelection(val[val.length - 1]); //只显示选中最后一个 这时val还是多选的列表(就是你选中的几个数据)
                } else if (val.length === 1) {
                    this.templateSelection = val[val.length - 1];
                }
                else if (val.length > 2) {
                    this.$refs.multipleTable.clearSelection(); 
                    
                }else {
                    this.templateSelection = []; //this.multipleTable是选中行的最后一条数据
                }
            
            },
    

      

  • 相关阅读:
    hash
    C#执行Sql事务处理
    数据库的锁表
    页面的刷新 和图片的替换
    单点登录 Webservice
    js 动态调用js文件
    .net生成EXCEL
    JS : 连续滚动
    引用指定类型的对象
    对象序列化为字符串
  • 原文地址:https://www.cnblogs.com/myleave/p/14010406.html
Copyright © 2011-2022 走看看