【问题标题】:React Admin - How To Hide Actions ButtonsReact Admin - 如何隐藏操作按钮
【发布时间】:2019-02-02 03:29:14
【问题描述】:

如何在 React-Admin 2.2.0 框架中隐藏操作按钮?

例如,我想只隐藏导出按钮,或者只显示刷新和导出按钮。

【问题讨论】:

    标签: reactjs react-admin


    【解决方案1】:

    嗯,我自己找到了解决方案。

    当你想隐藏所有按钮时:

    import { List, CardActions } from 'react-admin';
    
    const NoneActions = props => (
        <CardActions />
    );
    
    export const AdminList = (props) => (
        <List title="Admin List" {...props} actions={<NoneActions />}>
            ...
        </List>
    );
    

    当您只想显示重新加载按钮时:

    import { List, CardActions, RefreshButton } from 'react-admin';
    
    const ActionsRefresh = props => (
        <CardActions>
            <RefreshButton />
        </CardActions>
    );
    
    export const AdminList = (props) => (
        <List title="Admin List" {...props} actions={<ActionsRefresh />}>
            ...
        </List>
    );
    

    【讨论】:

    • 这是一个非常正确和可读的解决方案!您可以将其标记为已解决。它将帮助更多读者+1
    • 希望我能对此给予更多支持 - 文档非常复杂,并且在不提供简单上下文的情况下迫使其描述更加复杂。
    猜你喜欢
    • 2019-12-21
    • 1970-01-01
    • 2016-07-27
    • 2015-01-24
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 2021-01-27
    • 1970-01-01
    相关资源
    最近更新 更多