@selection-change="selectChange"
selectChange (val) {
if (val.length > 1) {
this.$refs.table.clearSelection();
this.$refs.table.toggleRowSelection(val.pop());
} else {
this.selectData = val
}
}
<template>
<el-table
:data="tableData"
border
stripe
ref="tableData"
@row-click="singleElection"
>
<el-table-column label="" width="65" align="center">
<template #header>
<el-button type="text" @click="clear"> 清除</el-button>
</template>
<template slot-scope="scope">
<el-radio
class="radio"
v-model="templateSelection"
:label="scope.$index"
> </el-radio
>
</template>
</el-table-column>
<el-table-column prop="id" label="ID"></el-table-column>
<el-table-column prop="title" label="标题"></el-table-column>
<el-table-column prop="priority" label="优先级"></el-table-column>
<el-table-column prop="state" label="状态"></el-table-column>
<el-table-column prop="dealingPeople" label="处理人"></el-table-column>
</el-table>
</template>
<script>
export default {
data() {
return {
templateSelection: "",
tableData: [
{
id: 1,
title: "111",
priority: "高",
state: 1,
dealingPeople: "admin",
},
{
id: 2,
title: "111",
priority: "中",
state: 2,
dealingPeople: "admin",
},
{
id: 3,
title: "111",
priority: "低",
state: 3,
dealingPeople: "admin",
},
],
};
},
methods: {
singleElection(row) {
console.log(row);
this.templateSelection = this.tableData.indexOf(row);
console.log(this.templateSelection);
this.templateRadio = row.id;
},
clear() {
this.templateRadio = null;
this.templateSelection = null;
},
},
};
</script>
<style lang="scss" scoped>
/deep/.el-radio .el-radio__label{
display: none;
}
</style>
<template>
<div>
<el-table
:data="cardIdlist"
ref="carTable"
border
tooltip-effect="dark"
highlight-current-row
style="width: 100%"
@current-change="handleSelectionChange2"
@selection-change="handleSelectionChange"
>
<el-table-column align="center" label="选择" width="75">
<template slot-scope="scope">
<div>
<el-radio
v-model="checked"
:label="scope.$index"
@change="test"
class="a11111111111111111"
> </el-radio
>
</div>
</template>
</el-table-column>
<el-table-column
type="selection"
width="50"
align="center"
></el-table-column>
<el-table-column
type="index"
label="序号"
align="center"
width="80"
></el-table-column>
<el-table-column
type="index"
prop="name"
label="name"
align="center"
width="80"
></el-table-column>
</el-table>
</div>
</template>
<script>
export default {
prop: {
field: {
type: String,
default: "",
},
},
data() {
return {
selectData: [],
checked: null,
cardIdlist: [
{ id: 1, name: 1 },
{ id: 2, name: 2 },
{ id: 3, name: 3 },
{ id: 4, name: 4 },
],
};
},
methods: {
test(val) {
console.log(val);
},
handleSelectionChange2(selection) {
console.log(selection);
if (this.field) {
this.checked = selection[field];
}
},
handleSelectionChange(selection) {
if (selection.length > 1) {
this.$refs.carTable.clearSelection();
this.$refs.carTable.toggleRowSelection(selection.pop());
} else {
this.selectData = selection;
}
},
},
};
</script>
<style lang="scss" scoped>
.a11111111111111111 /deep/ .el-radio__label {
display: none;
}
</style>
【推荐】国内首个AI IDE,深度理解中文开发场景,立即下载体验Trae
【推荐】编程新体验,更懂你的AI,立即体验豆包MarsCode编程助手
【推荐】抖音旗下AI助手豆包,你的智能百科全书,全免费不限次数
【推荐】轻量又高性能的 SSH 工具 IShell:AI 加持,快人一步
· 物流快递公司核心技术能力-地址解析分单基础技术分享
· 单线程的Redis速度为什么快?
· 展开说说关于C#中ORM框架的用法!
· Pantheons:用 TypeScript 打造主流大模型对话的一站式集成库
· SQL Server 2025 AI相关能力初探