// Provider import { createContext } from 'react' export const TestContext = createContext<any>(null) export const ContainerContext = createContext<any>(null) // 设置全局包裹 import { TestContext } from './Provider' const confDrawer: any = usekef(null) ... return ( <TestContext.Provider value={{ confDrawerShow: confDrawer.current?.show, }} <ConfEditDrawer ref={confDrawer} /> </TestContext.Provider> // 使用 import { TestContext } from '../../Provider'; const { confDrawerShow }= useContext<any>(TestContext) const onFn = () => { confDrawerShow('edit',{ data: xxxx }) }