Closed kopa-kongpan closed 3 months ago
ProTable requests 会发送两次请求
<ProTable rowSelection={{ // 自定义选择项参考: https://ant.design/components/table-cn/#components-table-demo-row-selection-custom // 注释该行则默认不显示下拉选项 selections: [Table.SELECTION_ALL, Table.SELECTION_INVERT], }} tableAlertRender={({ selectedRowKeys, onCleanSelected, }) => { setCurrentReqId(selectedRowKeys) return ( <Space size={24}> <span> 已选 {selectedRowKeys.length} 项 <a style={{marginInlineStart: 8}} onClick={onCleanSelected}> 取消选择 </a> </span> </Space> ); }} columns={columns} request={async (params, sorter, filter) => { console.log("++++++++++++++++") if (!filter.type) { filter.type = ['FuR'] } if (!filter.version) { filter.version = ['RB_V5R15C10'] } const datasource = await getReqItem(params, sorter, filter) setParamsFilter(datasource.filter_items) return datasource }} rowKey="reqId" pagination={{ showQuickJumper: true, }} search={{ layout: 'vertical', defaultCollapsed: false, }} dateFormatter="string" toolbar={{ title: '特性表格', // tooltip: '这是一个标题提示', }} toolBarRender={() => [ <Button type="primary" key="primary" onClick={onExportExcel}> 下载特性excel </Button>, <Button type="primary" key="primary" onClick={onExportRiskExcel}> 下载风险excel </Button>, ]} />
request 里 setParamsFilter 触发依赖更新了
setParamsFilter
onInlt 慢一些的,oinit 之后还会执行一下,可能params 就发生变化了
🐛 bug 描述
ProTable requests 会发送两次请求
📷 复现步骤
🏞 期望结果
💻 复现代码
© 版本信息
🚑 其他信息