vue中在table表格里点击行勾选复选框的效果

先看一下效果:在这里插入图片描述
这就是效果图,在项目中的效果,效果也简单就是想记录一下
下面附的代码是在页面做的实例:
html:

<template>
  <div class="hello">
    <el-table class="tablessp" :data="tableData" highlight-current-row @current-change="handleCurrentChange" ref="multipleTable" @select="handleSelect" @selection-change="handleSelectionChange"  border fit highlight-current-row
        style="width:700px;min-height:260px;margin-top:8px;" height="260"
        :header-cell-style="{background:'#199ED8'}">
        <el-table-column type="selection" width="60" align="center"></el-table-column>
          <el-table-column prop="workSheetCode" label="工单编号" min-width="180" align="center">
          </el-table-column>
          <el-table-column prop="subProductCode" label="部件编号" min-width="180" align="center">
          </el-table-column>
          <el-table-column prop="lineName" label="生产线名称" align="center" min-width="150">
          </el-table-column>
    </el-table>
   
  </div>
</template>

js

<script>
export default {
  name: 'HelloWorld',
  data () {
    return {
      msg: 'Welcome to Your Vue.js App',
      tableData: [{
            workSheetCode: '2016-05-02',
            subProductCode: '王小虎',
            lineName: '上海市普陀区金沙江路 1518 弄'
          }, {
           workSheetCode: '2016-05-02',
            subProductCode: '王小虎',
            lineName: '上海市普陀区金沙江路 1518 弄'
          }, {
           workSheetCode: '2016-05-02',
            subProductCode: '王小虎',
            lineName: '上海市普陀区金沙江路 1518 弄'
          }, {
            workSheetCode: '2016-05-02',
            subProductCode: '王小虎',
            lineName: '上海市普陀区金沙江路 1518 弄'
          }]
    }
  },
  methods:{
    handlck(tab, event) {
    },
    handleSelect(val,row){
      if (val.length > 1) {
        this.$refs.multipleTable.clearSelection() // 清空所有选择
        val.shift()
        this.$refs.multipleTable.toggleRowSelection(row) //  选中当前选择
      }
      let selected = val.length && val.indexOf(row) !== -1
     },
    handleSelectionChange(val){
     
    },
    // 单选行
    handleCurrentChange(val){
       this.$refs.multipleTable.clearSelection() // 清空所有选择
       this.$refs.multipleTable.toggleRowSelection(val) //  选中当前选择
    },
  }
}
</script>
<style>



.hello .el-table thead{
      color:#fff;
    }
 .tablessp thead tr .el-checkbox__input{
     display: none;
}

</style>
评论 2
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包

打赏作者

群狼之虎

你的鼓励将是我创作的最大动力

¥1 ¥2 ¥4 ¥6 ¥10 ¥20
扫码支付:¥1
获取中
扫码支付

您的余额不足,请更换扫码支付或充值

打赏作者

实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值