Vue如何實現(xiàn)el-table多選樣式變?yōu)閱芜x效果
Vue el-table多選樣式變?yōu)閱芜x效果
我最近在我的 項目開發(fā)中遇到一個需要將el-table復(fù)選框變單選的需求,同時單選某一行會異步調(diào)用接口,請求后臺數(shù)據(jù);我解決問題之后,覺得還是把這些改進寫清楚,方便 Vue 的初學(xué)者。
問題
(1)調(diào)用接口異步,可能會出現(xiàn)慢的接口更新快的接口的數(shù)據(jù)(解決);
效果圖
1、默認(rèn)進來的數(shù)據(jù)
2、選擇父類一條后的數(shù)據(jù)
3、每次切換父類復(fù)選框,只能查到對應(yīng)的數(shù)據(jù)
代碼:
<el-table ref="multipleTable" class="el-table-container" :header-cell-style="{ background: '#dee9fd66' }" height="260px" :row-style="{ height: '15px' }" size="mini" v-loading="loading" stripe border :data="tabledata" @selection-change="handleSelectionChange" @select-all="dialogCheck" @select="dialogCheck" >
handleSelectionChange(val) {}, dialogCheck: function (selection, row) { this.$refs.multipleTable.clearSelection(); if (selection.length === 0) { this.$refs.householdMember.queryFirstPage(''); return; } if (row) { const obj = JSON.parse(JSON.stringify(row)); this.$refs.householdMember.queryFirstPage(obj.id); this.$refs.multipleTable.toggleRowSelection(row, true); } },
其中:
this.$refs.householdMember.queryFirstPage(obj.id);和this.$refs.householdMember.queryFirstPage('');
為所調(diào)的接口
vue彈窗表格 多選變單選 隱藏左上角全選方塊
效果
給table標(biāo)簽加class
設(shè)置style樣式
::v-deep .statictable .el-table__header .el-checkbox__inner { display: none; }
總結(jié)
以上為個人經(jīng)驗,希望能給大家一個參考,也希望大家多多支持腳本之家。
相關(guān)文章
Vue常用API、高級API的相關(guān)總結(jié)
這篇文章主要介紹了Vue常用API、高級API的相關(guān)總結(jié),幫助大家更好的理解和學(xué)習(xí)使用vue框架,感興趣的朋友可以了解下2021-02-02Vue2與Vue3如何利用install自定義全局確認(rèn)框組件編寫
這篇文章主要介紹了Vue2與Vue3如何利用install自定義全局確認(rèn)框組件編寫方式,具有很好的參考價值,希望對大家有所幫助,如有錯誤或未考慮完全的地方,望不吝賜教2024-03-03