Vue Element-UI中el-table實現(xiàn)單選的示例代碼
更新時間:2023年12月15日 09:04:04 作者:夢之歸途
在element-ui中是為我們準備好了可直接使用的單選與多選屬性的,本文主要介紹了Vue Element-UI中el-table實現(xiàn)單選的示例代碼,具有一定的參考價值,感興趣的可以了解一下
實現(xiàn)方式: 給el-table-column
設(shè)置el-radio
<div class="default-page"> <el-table :data="accountList" v-loading="loading" highlight-current-row @current-change="handleCurrent" border height="250px"> <el-table-column width="60px"> <template v-slot="scope"> <!-- label值要與el-table數(shù)據(jù)id實現(xiàn)綁定 --> <el-radio v-model="unitInfo.userId" :label="scope.row.userId" @change="handleRowChange(scope.row)">{{""}}</el-radio> </template> </el-table-column> <el-table-column type="index" label="序號" /> <el-table-column prop="userId" label="賬號編號" /> <el-table-column prop="username" label="賬號名稱" /> <el-table-column prop='status' label="賬號狀態(tài)"> <template slot-scope="scope"> <el-tag :type="scope.row.status | filters('availableType')">{{ scope.row.status | filters('availableValue')}}</el-tag> </template> </el-table-column> </el-table> </div>
export default { data() { return { } }, methods: { // 方法一:與el-table @current-change方法 綁定 handleCurrent (val) { if (val) { this.unitInfo.userId = val.userId this.unitInfo.man = val.username } }, // 方法二:與el-radio @change方法 綁定 handleRowChange (data) { if (data) { this.unitInfo.userId = data.userId this.unitInfo.man = data.username } } } }
到此這篇關(guān)于Vue Element-UI中el-table實現(xiàn)單選的示例代碼的文章就介紹到這了,更多相關(guān)Element el-table單選內(nèi)容請搜索腳本之家以前的文章或繼續(xù)瀏覽下面的相關(guān)文章希望大家以后多多支持腳本之家!
相關(guān)文章
element上傳組件循環(huán)引用及簡單時間倒計時的實現(xiàn)
這篇文章主要介紹了element上傳組件循環(huán)引用及簡單時間倒計時的實現(xiàn),小編覺得挺不錯的,現(xiàn)在分享給大家,也給大家做個參考。一起跟隨小編過來看看吧2018-10-10詳解vue2.0+axios+mock+axios-mock+adapter實現(xiàn)登陸
這篇文章主要介紹了詳解vue2.0+axios+mock+axios-mock+adapter實現(xiàn)登陸,小編覺得挺不錯的,現(xiàn)在分享給大家,也給大家做個參考。一起跟隨小編過來看看吧2018-07-07