antd?table長表格出現(xiàn)滾動條的操作方法
如圖想實現(xiàn)如上圖所示,看antd table官方文檔想實現(xiàn)這個,介紹的很不詳細,實現(xiàn)起來一堆坑。
阿里云頁面的這種表格,拉伸起來也有很多bug,也不知道他的實現(xiàn)方法如何,我這邊介紹一種方法實現(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 }}小時</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; }
重點在于css設置絕對定位,columns每一項都要設置width,且width必須為固定px,不能是百分比(%),不然拉伸會被隱藏,至于單元格里面是否折行無所謂,剛開始就是在這里踩了很多坑
const columns = [ { title: '編號', dataIndex: 'id', // width: '3.4%', width: '58px' }, { title: '用戶平臺名', 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: '余額(單位:核時)', 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' } ]
實現(xiàn)出來的效果如下:
到此這篇關于antd table長表格出現(xiàn)滾動條的操作方法的文章就介紹到這了,更多相關antd table長表格滾動條內(nèi)容請搜索腳本之家以前的文章或繼續(xù)瀏覽下面的相關文章希望大家以后多多支持腳本之家!
相關文章
Quasar Input:type="number" 去掉上下小箭頭 實現(xiàn)加減按鈕樣式功能
這篇文章主要介紹了Quasar Input:type="number" 去掉上下小箭頭 實現(xiàn)加減按鈕樣式,本文通過實例代碼給大家介紹的非常詳細,對大家的學習或工作具有一定的參考借鑒價值,需要的朋友可以參考下2020-04-04使用JS+XML(數(shù)據(jù)島)實現(xiàn)分頁)
使用JS+XML(數(shù)據(jù)島)實現(xiàn)分頁)...2007-01-01