element table 表格控件实现单选功能

发布时间 2023-09-05 16:22:29作者: 张闲生

 

 

<el-table
    :data="tableData"
    border
    stripe
    ref="tableData"
    @row-click="singleElection">
    <el-table-column label="" width="65">
        <template slot-scope="scope">
            <el-radio class="radio" v-model="templateSelection" :label="scope.$index">&nbsp;</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>

 

data() {
    return {
        templateSelection: '',
        // 返回数据
        tableData: [
            {
                'id': 1,
                'title': '嘿嘿嘿',
                'priority': '',
                'state': 1,
                'dealingPeople': '小龙女'
                },
            {
                'id': 2,
                'title': '嘻嘻嘻',
                'priority': '',
                'state': 2,
                'dealingPeople': '小龙女'
            },
            {
                'id': 3,
                'title': '哈哈哈',
                'priority': '',
                'state': 3,
                'dealingPeople': '小龙女'
            },
            {
                'id': 3,
                'title': '哈哈哈',
                'priority': '',
                'state': 3,
                'dealingPeople': '小龙女'
            },
            {
                'id': 3,
                'title': '哈哈哈',
                'priority': '',
                'state': 3,
                'dealingPeople': '小龙女'
            },
            {
                'id': 3,
                'title': '哈哈哈',
                'priority': '',
                'state': 3,
                'dealingPeople': '小龙女'
            }
        ]
    }
}

 

 

 参考:https://www.jb51.net/article/256492.htm