antd-table 滚动条+分页

antd-table 滚动条+分页

方法一:

HTML

<div className="all-table">
                  <Table
                    className="auto-scroll-y"
                    size={'small'}
                    pagination={{
                      ...tablePagination,
                    }}
                    rowSelection={{
                      type: 'checkbox',
                      ...rowSelection,
                    }}
                    scroll={{ y: '100%', scrollToFirstRowOnChange: true }}
                    columns={columns}
                    dataSource={data}
                  />
                </div>

CSS

.all-table {
            padding: 0 24px;
            // 视情况而定
            height: ~'calc(100% - 240px)';

             .auto-scroll-y {
              width: 100%;
                     .ant-table.ant-table-small {
                         height: 100%;
                         	}

                     .ant-table-pagination.ant-pagination {
                            margin: 0;
                            padding: 32px 0;
                        	}                  
                        }
        }

在这里插入图片描述

方法二:

HTML

<div className="acontent-table">
          <Table
            className="auto-scroll-t"
            //   rowSelection={{
            //     type: 'checkbox',
            //     onChange: (selectedRowKeys) => {
            //       this.setState({
            //         delDataIDs: selectedRowKeys,
            //       });
            //     },
            //   }}
            pagination={{
              ...tableIndex,
              position: ['bottomCenter'],
              showQuickJumper: true,
              showSizeChanger: true,
              showTotal: () => `${Math.ceil(tableIndex.total / tableIndex.pageSize)}`,
              onChange: async (pageNo, pageSize) => {
                //   getCertificateInfoList(pageNo, pageSize);
                setTableIndex({
                  pageNo: pageNo,
                  pageSize: pageSize,
                  total: tableIndex.value,
                });
              },
            }}
            //calc(100% - 64px) 内容与 css .ant-table-body {  height: ~'calc(100% - 64px)'}一致
            scroll={{ y: 'calc(100% - 64px)', scrollToFirstRowOnChange: true }}
            columns={columns}
            dataSource={dataSource}
          />
        </div>

CSS

.acontent-table {
  width: 100%;
  height: 100%;
}

.auto-scroll-y {
  height: 100%;
}
.auto-scroll-t {
  height: 100%;
  .ant-spin-nested-loading .ant-spin-container .ant-table .ant-table-container .ant-table-body {
  //与scroll={{ y: 'calc(100% - 64px)', scrollToFirstRowOnChange: true }}一致
    height: ~'calc(100% - 64px)';
  }
}

在这里插入图片描述

  • 0
    点赞
  • 1
    收藏
    觉得还不错? 一键收藏
  • 0
    评论
你可以使用antd-mobile和react-router-dom来实现tabs功能。首先,你需要安装antd-mobile和react-router-dom依赖包。 ```shell npm install antd-mobile react-router-dom ``` 接下来,你可以创建一个Tabs组件,并在其使用antd-mobile的TabBar组件来实现tabs布局。然后,使用react-router-dom的Route组件来定义每个tab对应的页面。 ```jsx import React from 'react'; import { TabBar } from 'antd-mobile'; import { BrowserRouter as Router, Route, Link } from 'react-router-dom'; const Tabs = () => { const tabItems = [ { title: 'Tab 1', path: '/tab1', component: Tab1 }, { title: 'Tab 2', path: '/tab2', component: Tab2 }, { title: 'Tab 3', path: '/tab3', component: Tab3 }, ]; const renderTabs = () => { return tabItems.map((item) => ( <TabBar.Item key={item.path} title={item.title} icon={<div />} selectedIcon={<div />} selected={window.location.pathname === item.path} onPress={() => { window.location.href = item.path; }} /> )); }; return ( <Router> <div style={{ position: 'fixed', width: '100%', bottom: 0 }}> <TabBar>{renderTabs()}</TabBar> </div> {/* Define routes */} {tabItems.map((item) => ( <Route key={item.path} path={item.path} component={item.component} /> ))} </Router> ); }; const Tab1 = () => <div>Tab 1 content</div>; const Tab2 = () => <div>Tab 2 content</div>; const Tab3 = () => <div>Tab 3 content</div>; export default Tabs; ``` 在上面的代码,我们定义了三个tab,分别对应不同的路径和组件。通过点击tab,我们可以切换显示不同的内容。你可以根据自己的需求修改tab的数量、标题、路径和对应的组件。 希望这可以帮助你实现antd-mobile和react-router-dom的tabs功能!

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值