zoukankan      html  css  js  c++  java
  • Element UI table参数中的selectable的使用

    Element UI table参数中的selectable的使用中遇到的坑:
    页面:

                 <el-table-column :selectable='selectable' type="selection" :reserve-selection="true">
                 </el-table-column>
       

    网上搜了说这样:

                                
    selectable(row,index) {
    
           if(row.id==="10001"){
               return false
           }else {
               return true
           }
        }
    返回true 即为可以勾选
    反之 不可勾选

    但是嘞 我的数据是一个id数组
    于是我改成了这样:

       selectable(row,index) {
            this.arr(el=>{
                if(el==row.id){
                    return false;
                }else{
                    return true;
                }
            })
        }

    然后不行,只渲染数组第一位 不能勾选;for循环也是一样的结果;这可如何是好;

    说时迟那时快:灵光一现,改成了这样

     selectable(row,index) {
           if(this.arr.some(el=>{return el===row.id})){
               return false;
           }else{
               return true;
           }
        }

    完美解决!

  • 相关阅读:
    2017.4.18下午
    2017.4.18上午
    2017.4.17上午
    2017.4.14下午
    2017.4.14上午
    4.17下午
    4.17上午
    4.13下午
    4.13上午
    4.10上午
  • 原文地址:https://www.cnblogs.com/10manongit/p/12788333.html
Copyright © 2011-2022 走看看