【问题标题】:how to make the React material-UI Expansion Panel open upwards?如何让 React Material-UI 扩展面板向上打开?
【发布时间】:2020-08-10 17:43:34
【问题描述】:

我查看了this answer,但它在 ReactJs 中不起作用。 ReactJs Material-Ui中如何让扩展面板向上打开?

【问题讨论】:

    标签: reactjs material-ui react-material


    【解决方案1】:

    您好,请检查此示例以了解反应。希望对你有帮助:

    import React from 'react';
    import {makeStyles} from '@material-ui/core/styles';
    import ExpansionPanel from '@material-ui/core/ExpansionPanel';
    import ExpansionPanelSummary from '@material-ui/core/ExpansionPanelSummary';
    import ExpansionPanelDetails from '@material-ui/core/ExpansionPanelDetails';
    import Typography from '@material-ui/core/Typography';
    import ExpandMoreIcon from '@material-ui/icons/ExpandMore';
    
    const useStyles = makeStyles((theme) => ({
        root: {
            width: '100%',
        },
        heading: {
            fontSize: theme.typography.pxToRem(15),
            fontWeight: theme.typography.fontWeightRegular,
        },
    }));
    
    export default function SimpleExpansionPanel() {
        const classes = useStyles();
    
        return (
            <div className={classes.root}>
                <ExpansionPanel>
                    <ExpansionPanelSummary
                        expandIcon={<ExpandMoreIcon/>}
                        aria-controls="panel1a-content"
                        id="panel1a-header"
                    >
                        <Typography className={classes.heading}>Expansion Panel 1</Typography>
                    </ExpansionPanelSummary>
                    <ExpansionPanelDetails>
                        <Typography>
                            Lorem ipsum dolor sit amet, consectetur adipiscing elit. Suspendisse malesuada lacus ex,
                            sit amet blandit leo lobortis eget.
                        </Typography>
                    </ExpansionPanelDetails>
                </ExpansionPanel>
                <ExpansionPanel>
                    <ExpansionPanelSummary
                        expandIcon={<ExpandMoreIcon/>}
                        aria-controls="panel2a-content"
                        id="panel2a-header"
                    >
                        <Typography className={classes.heading}>Expansion Panel 2</Typography>
                    </ExpansionPanelSummary>
                    <ExpansionPanelDetails>
                        <Typography>
                            Lorem ipsum dolor sit amet, consectetur adipiscing elit. Suspendisse malesuada lacus ex,
                            sit amet blandit leo lobortis eget.
                        </Typography>
                    </ExpansionPanelDetails>
                </ExpansionPanel>
                <ExpansionPanel disabled>
                    <ExpansionPanelSummary
                        expandIcon={<ExpandMoreIcon/>}
                        aria-controls="panel3a-content"
                        id="panel3a-header"
                    >
                        <Typography className={classes.heading}>Disabled Expansion Panel</Typography>
                    </ExpansionPanelSummary>
                </ExpansionPanel>
            </div>
        );
    }
    

    Source

    【讨论】:

    • 感谢您的回复,但它是向下打开的。我想&lt;ExpansionPanelDetails&gt; 向上打开。我的意思是这样的:link
    • @SamNickson,我检查了材质 ui 扩展面板,没有发现任何向上打开的东西。我们需要对其进行自定义以利用此行为。
    • 是的,我也这样做了,但找不到任何东西。也许我们必须用另一种方式来解决它。
    猜你喜欢
    • 1970-01-01
    • 2020-08-09
    • 2021-09-03
    • 1970-01-01
    • 2019-10-14
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 2019-03-17
    相关资源
    最近更新 更多