elment UI中的table判断当前行是否勾选复选框

elment UI中的table判断当前行是否勾选复选框

el-table中绑定select事件

<el-table
                :data="MergeProjectList2"
                style="width: 100%"
                @select='onTableSelect'
                @selection-change="handleSelectionChange">

data中定义一个选中的当前行变量

rows:[],                   //选中的当前行

methods中定义select事件

//判断当前行有没有被选中
            onTableSelect(rows, row) {
                this.rows = rows
            },

el-table中绑定判断事件

 <template slot-scope="scope">
                    <el-button @click="getBuildList(scope.row)">同步</el-button>
                </template>

methods中定义判断事件

 getBuildList(row){
  
                let selected = this.rows.length && this.rows.indexOf(row) !== -1
                //console.log('是否选中',selected)
                if(selected === true){
                     //当前行被选中  
                }else{      
                   //当前行未被选中
                }             
            },
发布了4 篇原创文章 · 获赞 4 · 访问量 7053

猜你喜欢

转载自blog.csdn.net/Ivan_Jin_666/article/details/100987510