
Security News
Axios Maintainer Confirms Social Engineering Attack Behind npm Compromise
Axios compromise traced to social engineering, showing how attacks on maintainers can bypass controls and expose the broader software supply chain.
@aliwind/rc-table
Advanced tools
@aliwind/rc-table 是基于 Table 组件的增强实现,提供控制台标准化的数据列表
MDXInstruction:importDemo:BasicDemo
| name | type | default | desc |
|---|---|---|---|
| ...Table.props | 继承 wind <Table> 组件中的所有属性 | ||
| pagination | object|React.Element | 分页器 | |
| selection | function | 选择器 | |
| operation | function | 操作器 | |
| search | object|React.Element | 搜索器 | |
| affixActionBar | boolean|string|array | false | 动作区滚动锁定, 在 rc-table 中最多会有上下两个动作区, 可以指定 affixActionBar 的值为 true 来同时开启两个动作区的滚动锁定特性, 也可以通过字符串声明 `affixActionBar: ('bottom' |
| fixedBarZIndex | number | 1000 | 当 affixActionBar 开启时,锁定的动作区的 z-index |
可以将 @aliwind/rc-table 看做一个包含了不同功能区的 Table,不同的功能区中使用的组件可以看做是 Table 的卫星组件
|Operation | Search|
----------------------------
| Table |
----------------------------
|Selection | Pagination|
分页器 (Pagination) 是数据列表中常用的功能组件,根据UED规约,位于数据表格的右下角区域,在 @aliwind/rc-table 中,可以通过 pagination 属性来定义分页器的属性和行为
在 @aliwind/rc-table 中,预设了符合UED规约的分页器组件,在绝大多数情况下,你只需要关心分页器的部分属性,比如:
current 当前分页页码total 当前数据总条目数pageSize 每页数据条目数onChange 分页发生变化触发行为(通常是请求列表的数据并重绘)预设的分页器使用了响应式设计:
mini 的分页组件,强制不显示 pageSizeList 和跳转 inputsimple 的分页组件,强制不显示 pageSizeList 和跳转 inputnormal 的分页组件,强制不显示 pageSizeList 和跳转 inputnormal 的分页组件import React, { Component } from 'react'
import Table from '@aliwind/rc-table'
class MyTable extends Component {
state = {
current: 1,
total: 100,
pageSize: 10,
list: [], // 需要被填充的列表数据
columns: [], // 列表列定义
}
onPageChange = (nextPageNumber) => {
this.setState({
list: [], // 模拟数据变化
})
}
render() {
const { list, columns, ...paginationProps } = this.state
paginationProps.onChange = this.onPageChange
return (
<Table
dataSource={list}
columns={columns}
pagination={paginationProps}
/>
)
}
}
在大多数情况下,直接向 pagination 属性传入分页器的属性定义就可以完成标准场景的分页展示。如果你有一些情况下需要自定义这个区域的内容,也可以传入一个自定义组件来完成特定的业务需求
import React, { Component } from 'react'
import { Button } from '@aliwind/component'
import Table from '@aliwind/rc-table'
‘
class MyTable extends Component {
onButtonClick = () => {
console.log('Clicked')
}
render() {
return (
<Table
pagination={
<>
<Button type="primary" onClick={this.onButtonClick}>
<Table.Pagination {...this.props.pagination} />
</>
}
{...this.props}
/>
)
}
}
批量操作 (Selection) 也是常用的功能组件,在 @aliwind/rc-table 中,由于需要和 Table 内置的行选择进行交互,在底层使用了 Selection.Provider 重新封装了 Table 的行为,通过 Context API 对行选择的相关数据及行为进行传递交互,位于 Table 的左下角
可以通过 selection 属性对批量选择操作进行定义
在@aliwind/rc-table中,预设了符合UED规约和业务场景的 Selection 组件:
使用 render 函数就可以访问到和行选择相关的数据和行为:
selectedRowKeys 访问已经选中的行数据的主键isSelectedAll 是否已经全部选中当前页的数据selectAll 全选当前页所有数据import React from 'react'
import { Button } from '@aliwind/component'
import Table from '@aliwind/rc-table'
const MyTable = (props) => (
<Table
selection={
({ selectedRowKeys }) => (
<>
<Button disabled={selectedRowKeys.length === 0}>
Delete
({selectedRowKeys.length})
</Button>
</>
)
}
{...props}
/>
)
export default MyTable
根本不需要
位于 Table 左上角的操作区,没有任何预设组件和行为,通过 operation 来定义操作区的内容
由于没啥可讲的,直接上示例
import React from 'react'
import { Button } from '@aliwind/component'
import Table from '@aliwind/rc-table'
const MyTable = (props) => {
const { onCreate, onRefresh, ...tableProps } = props
return (
<Table
operation={
<>
<Button type="primary" onClick={onCreate}>Create New Record</Button>
<Button onClick={onRefresh}>Refresh</Button>
</>
}
{...tableProps}
/>
)
}
export default MyTable
搜索区域 (Search) 也会经常使用到,在 @aliwind/rc-table 中预设了符合UED规约的搜索组件,在大多数场景下,你只需要关注一部分 Search 组件的属性:
value 搜索框内容filter 条件筛选定义onSearch 搜索行为和 Pagination 的定义基本一致,只需要传入 Search 组件的属性对象即可
import React form 'react'
import Table from '@aliwind/rc-table'
const filters = [
{ value: 'name', label: '名称' },
{ value: 'id', label: 'id },
]
const MyTable = (props) => {
const { onSearch, ...tableProps } = props
const search = {
filter: filters,
onSearch
}
return (
<Table
search={search}
{...tableProps}
/>
)
}
export default MyTable
请参考上文 Pagination 中自定义组件的示例
FAQs
React component for Alibaba Cloud.
We found that @aliwind/rc-table demonstrated a not healthy version release cadence and project activity because the last version was released a year ago. It has 3 open source maintainers collaborating on the project.
Did you know?

Socket for GitHub automatically highlights issues in each pull request and monitors the health of all your open source dependencies. Discover the contents of your packages and block harmful activity before you install or update your dependencies.

Security News
Axios compromise traced to social engineering, showing how attacks on maintainers can bypass controls and expose the broader software supply chain.

Security News
Node.js has paused its bug bounty program after funding ended, removing payouts for vulnerability reports but keeping its security process unchanged.

Security News
The Axios compromise shows how time-dependent dependency resolution makes exposure harder to detect and contain.