【发布时间】:2021-12-31 11:50:56
【问题描述】:
【问题讨论】:
标签: javascript reactjs user-interface html-table react-hooks
【问题讨论】:
标签: javascript reactjs user-interface html-table react-hooks
我已经完成了弹出窗口的简单实现。我不明白垂直弹出窗口,所以我实现了一般弹出窗口。
链接:https://jsfiddle.net/himanshu1024/hyvqkfwu/2/
问题是,只有在选择/保存一行时才会显示弹出窗口,如果 selectedRow 为 NULL,则 NULL && <div id="popup"></div> 将是 false,所以没有弹出窗口将显示出来。
您还可以在此处查看其他类似代码:https://www.c-sharpcorner.com/article/how-to-create-a-modal-pop-up-in-reactjs-appliaction/
【讨论】:
请参考下面使用材质 ui popover 组件的示例
import * as React from 'react';
import Popover from '@mui/material/Popover';
import Typography from '@mui/material/Typography';
import Button from '@mui/material/Button';
export default function BasicPopover() {
const [anchorEl, setAnchorEl] = React.useState(null);
const handleClick = (event) => {
setAnchorEl(event.currentTarget);
};
const handleClose = () => {
setAnchorEl(null);
};
const open = Boolean(anchorEl);
const id = open ? 'simple-popover' : undefined;
return (
<div>
<Button aria-describedby={id} variant="contained" onClick={handleClick}>
Open Popover
</Button>
<Popover
id={id}
open={open}
anchorEl={anchorEl}
onClose={handleClose}
anchorOrigin={{
vertical: 'bottom',
horizontal: 'left',
}}
>
<Typography sx={{ p: 2 }}>The content of the Popover.</Typography>
</Popover>
</div>
);
}
您可以参考此链接material ui 并按照自己的方式进行自定义
【讨论】: