zoukankan      html  css  js  c++  java
  • element-ui Checkbox 实现单选

    html 部分

    <el-table id="tables" ref="multipleTable" row-key="id" 
        :data="tableData" 
         max-height="450" 
         border 
         style=" 100%" 
         @selection-change="handleSelectionChange" //将用到此
         :header-cell-style="{background:'#F8F8FA',color:'#606266',fontSize:'13px',fontWeight:'bold'}"
       >
         <el-table-column type="selection" width="60" align="center" :reserve-selection="true"></el-table-column>
         <el-table-column prop="id" label="序号" width="120" align="center"> </el-table-column>
         <el-table-column prop="name" label="话题名称" align="center" show-overflow-tooltip> </el-table-column>
     </el-table>

    js部分

    handleSelectionChange(val) {
      if(val.length >=2){
         // 删除索引为0的
         // console.log(val.splice(0,val.length-1),'被删除的')
         let arrays = val.splice(0,val.length-1)
         arrays.forEach(row => {
           this.$refs.multipleTable.toggleRowSelection(row); //除了当前点击的,其他的全部取消选中
         })
      }
      // console.log(val,'最后得到的')this.array = val
    }
    <el-table id="tables" ref="multipleTable" row-key="id" :data="tableDatamax-height="450" border style=" 100%" @selection-change="handleSelectionChange" :header-cell-style="{background:'#F8F8FA',color:'#606266',fontSize:'13px',fontWeight:'bold'}">
                <el-table-column type="selection" width="60" align="center" :reserve-selection="true"></el-table-column>
                <el-table-column prop="id" label="序号" width="120" align="center"> </el-table-column>
                <el-table-column prop="name" label="话题名称" align="center" show-overflow-tooltip> </el-table-column>
                <el-table-column prop="introduction" label="话题内容" show-overflow-tooltip align="center"></el-table-column>
                <el-table-column prop="creatorName" label="创建人" align="center" show-overflow-tooltip> </el-table-column>
              </el-table>
  • 相关阅读:
    bert系列一:《Attention is all you need》论文解读
    维特比算法及python实现
    手写高斯混合聚类算法
    强化学习应用于游戏Tic-Tac-Toe
    EM算法分析
    手写LVQ(学习向量量化)聚类算法
    手写k-means算法
    tensorflow增强学习应用于一个小游戏
    Opencv之LBP特征(算法)
    手写朴素贝叶斯(naive_bayes)分类算法
  • 原文地址:https://www.cnblogs.com/tlfe/p/12218272.html
Copyright © 2011-2022 走看看