对于像 Tooltip Popover Select TreeSelect Modal Drawer 等组件在滚动时可能会跟随鼠标进行滚动, 对于用户体验来说很不友好, 做一些简单的处理, 均提供了如: getContainer getPopupContainer API, 但针对 DatePicker 等日期组件使用之后貌似没什么反应, 而是通过 getCalendarContainer
    **

    1. /**
    2. * 代替全局的 ConfigProvider
    3. * getPopupContainer: https://3x.ant.design/components/config-provider-cn/#API
    4. */
    5. import React, { ReactNode, FC } from 'react';
    6. export interface TriggerContainerProps {
    7. children: ReactNode;
    8. }
    9. export const getPopupContainer = (node: HTMLElement) => {
    10. if (node) {
    11. return node.parentNode as HTMLElement;
    12. }
    13. return document.body;
    14. };
    15. const TriggerContainer: FC<TriggerContainerProps> = props => {
    16. const { children, ...restProps } = props;
    17. const newProps = {
    18. ...restProps,
    19. getPopupContainer,
    20. getCalendarContainer: getPopupContainer,
    21. };
    22. // @ts-ignore
    23. return React.cloneElement(children, newProps);
    24. };
    25. export default TriggerContainer;

    也可以通过全局配置 ConfigProvider 提供的 getPopupContainer 进行配置