【发布时间】:2019-10-17 12:26:07
【问题描述】:
我正在使用map() 循环渲染一堆Player 组件,我想使用来自material-ui 的某种Grid 水平并排显示它们。
现在组件渲染如下:
我想像这样渲染它们:
到目前为止,我已经尝试过这个Grid:
render() {
const { multipleVideoSource } = this.state;
return (
multipleVideoSource !== null ?
multipleVideoSource.map(src => (
<div style={{ row: 'horizontal' }}>
<Grid container spacing={24}>
<Grid item xs={4}>
<Player key={src} height={500} fluid={false}>
<ControlBar autoHide={false} className="my-class" />
<BigPlayButton position="center" />
<HLSSource isVideoChild src={src} />
</Player>
</Grid>
</Grid>
</div>
))
: "Only one video"
);
};
但没有运气。任何想法如何解决这个问题?
提前谢谢你。
【问题讨论】:
-
你在使用 ReactJS 吗?如果是这样,请将其添加为标签。
-
@Rojo 我是,已添加标签。
-
容器需要在循环之外,这样你就只有一个容器(目前每个项目都有一个单独的容器)。
-
@RyanCogswell 解决了这个问题,非常感谢。
-
将容器设置为 flex 然后设置 flex-direction: row 我想应该会有所帮助。
标签: javascript css reactjs grid material-ui