el-table 添加单选

这篇博客详细介绍了如何在Vue项目中利用Element UI的el-table组件实现表格选择功能。通过监听current-change事件和使用el-radio进行单选操作,同时展示了数据绑定和方法调用以获取选中行的数据。
摘要由CSDN通过智能技术生成
        <el-table
          ref="multipleTable"
          :data="productlist"
          :header-cell-style="{ background: '#F4F4F4' }"
          border
          @current-change="handleRowChange"
        >
          <el-table-column label="选择" width="80">
               <template slot-scope="scope">
                <el-radio v-model="selectId" :label="scope.row.name"
                  ><i></i
                ></el-radio>
              </template>
          </el-table-column>
          <el-table-column label="名称" prop="name">
            <template slot-scope="scope">
              {{ scope.row.name }}
            </template>
          </el-table-column>
          <el-table-column label="学工号" prop="productName" />
        </el-table>
      <span slot="footer" class="dialog-footer">
        <el-button
          type="primary"
          :loading="btnLoading"
          size="mini"
          @click="ConfirmSelect"
        >确 定</el-button>
      </span>
data(){

      // 表格人员数组
      productlist: [
        {
          productName: '10010',
          name: '张三',
          checked: false
        },
        {
          productName: '10010',
          name: '李四',
          checked: false
        }
      ],
      // 选中name
    selectId: null,
     // 选中数据
      selectData: {},
}


  methods: {
	handleRowChange(value) {
		this.selectData = value
	}
     /**
     * 确认
     */
    ConfirmSelect(form, electType) {
        if (this.selectData !== null) {
          this.selectId = this.selectData.name;
        }
        console.log(this.selectId,this.selectData)
    },
 
}
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

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

余额充值