antd?table長表格出現(xiàn)滾動(dòng)條的操作方法
如圖想實(shí)現(xiàn)如上圖所示,看antd table官方文檔想實(shí)現(xiàn)這個(gè),介紹的很不詳細(xì),實(shí)現(xiàn)起來一堆坑。
阿里云頁面的這種表格,拉伸起來也有很多bug,也不知道他的實(shí)現(xiàn)方法如何,我這邊介紹一種方法實(shí)現(xiàn)如下,遇到拉伸也不怕…
<div class="content"> <a-table :columns="columns" :data-source="dataSource" :row-key="record => record.id" :pagination="pagination" :scroll="{ x: '1400px' | true }" class="charge-table" @change="handleTableChange" > <div slot="trialQuota" slot-scope="text">{{ text }}小時(shí)</div> <template slot="action" slot-scope="text, record"> <a-button type="link" style="margin-left: -8px" @click="openDetail(text, record)"> 詳情 </a-button> <a-button type="link" @click="openCharge(text)"> 充賬 </a-button> <a-button type="link" :disabled="text.tryData" @click="onTry(text)"> 試用 </a-button> </template> </a-table> </div>
.content { flex: 1; background: #ffffff; border-radius: 8px; padding: 0 20px; position: relative; } /deep/.ant-spin-nested-loading { position: absolute; left: 20px; right: 20px; }
重點(diǎn)在于css設(shè)置絕對定位,columns每一項(xiàng)都要設(shè)置width,且width必須為固定px,不能是百分比(%),不然拉伸會(huì)被隱藏,至于單元格里面是否折行無所謂,剛開始就是在這里踩了很多坑
const columns = [ { title: '編號', dataIndex: 'id', // width: '3.4%', width: '58px' }, { title: '用戶平臺(tái)名', dataIndex: 'ourUserName', // width: '6.9%', width: '173px' }, { title: '用戶外部名', dataIndex: 'userName', // scopedSlots: { customRender: 'userName' }, // width: '166px' // width: '6.9%', width: '145px', ellipsis: true }, { title: '用戶組', dataIndex: 'groupDesc', // scopedSlots: { customRender: 'groupDesc' }, // width: '10%', ellipsis: true, width: '198px' }, { title: '用戶組賬戶', dataIndex: 'groupName', // width: '8.4%', width: '145px' }, { title: '余額(單位:核時(shí))', dataIndex: 'corestimeBalance', // width: '7.9%', width: '129px' }, { title: 'VPN地址', dataIndex: 'vpnAddress', scopedSlots: { customRender: 'vpnAddress' }, // width: '13.2%', width: '217px' // ellipsis: true, // width: '246px' // customCell: () => { // return { // style: { // 'min-width': '300px', // 'white-space': 'nowrap', // 'text-overflow': 'ellipsis' // } // } // } // customCell: () => { // return { // style: { // 'color':'yellow', // 'width': '246px' // } // } // }, // customHeaderCell: () => { // return { // style: { // 'color':'yellow', // 'width': '246px' // } // } // } }, { title: 'SSH地址', dataIndex: 'sshAddress', ellipsis: true, // width: '13.2%', width: '245px' }, { title: '試用方式', dataIndex: 'trialMethod', ellipsis: true, // width: '7.8%', width: '128px' }, { title: '試用額度', dataIndex: 'trialQuota', // width: '6.9%', width: '104px', scopedSlots: { customRender: 'trialQuota' } }, { title: '集群操作', key: 'action', scopedSlots: { customRender: 'action' }, fixed: 'right', width: '132px' } ]
實(shí)現(xiàn)出來的效果如下:
到此這篇關(guān)于antd table長表格出現(xiàn)滾動(dòng)條的操作方法的文章就介紹到這了,更多相關(guān)antd table長表格滾動(dòng)條內(nèi)容請搜索腳本之家以前的文章或繼續(xù)瀏覽下面的相關(guān)文章希望大家以后多多支持腳本之家!
相關(guān)文章
基于 D3.js 繪制動(dòng)態(tài)進(jìn)度條的實(shí)例詳解
D3是一個(gè)被數(shù)據(jù)驅(qū)動(dòng)的文檔。這篇文章主要介紹了基于 D3.js 繪制動(dòng)態(tài)進(jìn)度條的方法,需要的朋友可以參考下2018-02-02js實(shí)現(xiàn)form自動(dòng)完成功能
2008-02-02Quasar Input:type="number" 去掉上下小箭頭 實(shí)現(xiàn)加減按鈕樣式功能
這篇文章主要介紹了Quasar Input:type="number" 去掉上下小箭頭 實(shí)現(xiàn)加減按鈕樣式,本文通過實(shí)例代碼給大家介紹的非常詳細(xì),對大家的學(xué)習(xí)或工作具有一定的參考借鑒價(jià)值,需要的朋友可以參考下2020-04-04js實(shí)現(xiàn)計(jì)時(shí)器秒表功能
這篇文章主要為大家詳細(xì)介紹了js實(shí)現(xiàn)計(jì)時(shí)器秒表功能,文中示例代碼介紹的非常詳細(xì),具有一定的參考價(jià)值,感興趣的小伙伴們可以參考一下2019-12-12使用JS+XML(數(shù)據(jù)島)實(shí)現(xiàn)分頁)
使用JS+XML(數(shù)據(jù)島)實(shí)現(xiàn)分頁)...2007-01-01微信小程序轉(zhuǎn)發(fā)事件實(shí)現(xiàn)解析
這篇文章主要介紹了微信小程序轉(zhuǎn)發(fā)事件實(shí)現(xiàn)解析,文中通過示例代碼介紹的非常詳細(xì),對大家的學(xué)習(xí)或者工作具有一定的參考學(xué)習(xí)價(jià)值,需要的朋友可以參考下2019-10-10使用微信小程序API,調(diào)用微信的各種內(nèi)置能力。
微信小程序如何使用小程序API,去調(diào)用微信提供的各種內(nèi)置能力(即微信API)。小程序開發(fā)框架提供豐富的微信原生API,可以方便的調(diào)起微信提供的能力,如獲取用戶信息,本地存儲(chǔ),支付功能等。2022-12-12