原因:react 对比columns 数组为原数组,内存地址没变;
解决办法:用es6的扩展,生成新数组,添加操作列operateCol
setTableColumns([...tableColums,operateCol])
自定义hook enter搜索,使用方法
export const useEnterSearch = (getListFunc, dependenciesArr) => { useEffect(() => { const handleDown = (event: any) => { if (event.key == 'Enter') { getListFunc(); } }; window.addEventListener('keydown', handleDown); return () => { window.removeEventListener('keydown', handleDown); }; }, dependenciesArr); };
页面使用
useEnterSearch(getList, [searchProductVal, searchTypeVal, orgVal, accessionVal, dataSource, issueTime]); 标签:handleDown,useEnterSearch,表格,添加,数组,antd From: https://www.cnblogs.com/xiaoyaoweb/p/16792527.html