element?table?表格控件實(shí)現(xiàn)單選功能
項(xiàng)目中實(shí)現(xiàn) table 表格控件單選功能,如圖:

基本代碼如下:
1、template 代碼中:
<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"> </el-radio>
</template>
</el-table-column>
<el-table-column prop="id" label="ID"></el-table-column>
<el-table-column prop="title" label="標(biāo)題"></el-table-column>
<el-table-column prop="priority" label="優(yōu)先級(jí)"></el-table-column>
<el-table-column prop="state" label="狀態(tài)"></el-table-column>
<el-table-column prop="dealingPeople" label="處理人"></el-table-column>
</el-table>注意:
<el-radio class="radio" v-model="templateSelection" :label="scope.$index"> </el-radio>
這里寫   的目的是為了頁面不顯示內(nèi)容,只顯示單選操作
2、data 代碼中:
data() {
return {
templateSelection: '',
// 返回?cái)?shù)據(jù)
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': '小龍女'
}
]
}
}3、methods 代碼中:
singleElection (row) {
this.templateSelection = this.tableData.indexOf(row);
this.templateRadio = row.id;
},到此這篇關(guān)于element table 表格控件實(shí)現(xiàn)單選功能的文章就介紹到這了,更多相關(guān)element table 表格單選內(nèi)容請(qǐng)搜索腳本之家以前的文章或繼續(xù)瀏覽下面的相關(guān)文章希望大家以后多多支持腳本之家!
相關(guān)文章
Vue單頁式應(yīng)用(Hash模式下)實(shí)現(xiàn)微信分享的實(shí)例
本篇文章介紹了Vue單頁式應(yīng)用(Hash模式下)實(shí)現(xiàn)微信分享的實(shí)例,具有一定的參考價(jià)值,感興趣的小伙伴們可以參考一下2017-07-07
vue如何使用 Slot 分發(fā)內(nèi)容實(shí)例詳解
本篇文章主要介紹了vue如何使用 Slot 分發(fā)內(nèi)容實(shí)例詳解,小編覺得挺不錯(cuò)的,現(xiàn)在分享給大家,也給大家做個(gè)參考。一起跟隨小編過來看看吧2017-09-09
vue實(shí)現(xiàn)圖片路徑轉(zhuǎn)二進(jìn)制文件流(binary)
這篇文章主要介紹了vue實(shí)現(xiàn)圖片路徑轉(zhuǎn)二進(jìn)制文件流(binary),具有很好的參考價(jià)值,希望對(duì)大家有所幫助。如有錯(cuò)誤或未考慮完全的地方,望不吝賜教2022-06-06
vue項(xiàng)目打包后提交到git上為什么沒有dist這個(gè)文件的解決方法
這篇文章主要介紹了vue項(xiàng)目打包后提交到git上為什么沒有dist這個(gè)文件的解決方法,本文給大家介紹的非常詳細(xì),對(duì)大家的學(xué)習(xí)或工作具有一定的參考借鑒價(jià)值,需要的朋友可以參考下2020-09-09
Vue淺析axios二次封裝與節(jié)流及防抖的實(shí)現(xiàn)
axios是基于promise的HTTP庫,可以使用在瀏覽器和node.js中,它不是vue的第三方插件,vue-axios是axios集成到Vue.js的小包裝器,可以像插件一樣安裝使用:Vue.use(VueAxios,?axios),本文給大家介紹axios的二次封裝和節(jié)流與防抖2022-08-08

