栏目分类:
子分类:
返回
名师互学网用户登录
快速导航关闭
当前搜索
当前分类
子分类
实用工具
热门搜索
名师互学网 > IT > 面试经验 > 面试问答

Material-UI Grid不会隐藏使用显示

面试问答 更新时间: 发布时间: IT归档 最新发布 模块sitemap 名妆网 法律咨询 聚返吧 英语巴士网 伯小乐 网商动力

Material-UI Grid不会隐藏使用显示

该风格的功能都不会自动支持

Grid
组件。

利用样式功能的最简单方法是使用Box组件。该

Box
组件使所有样式功能(例如display)都可用。所述
Box
组件具有组件道具(默认为
div
)使用,以支持
Box
对风格函数添加到另一组件。

Grid
部件一样有分量的道具,让你可以有一个
Grid
是代表其渲染到
Box
或者
Box
委托给一个
Grid

下面的示例(基于您的代码)展示了

Box
以及
Grid
一起使用的两种方式。

import React from "react";import ReactDOM from "react-dom";import Grid from "@material-ui/core/Grid";import Box from "@material-ui/core/Box";import { makeStyles } from "@material-ui/core/styles";const useStyles = makeStyles({  gridItem: {    border: "1px solid red"  }});function App() {  const classes = useStyles();  return (    <Grid      container      spacing={1}      direction="row"      justify="center"      alignItems="center"    >      <Grid className={classes.gridItem} item xs={12} lg={6}>        <span>XX</span>      </Grid>      <Box        component={Grid}        className={classes.gridItem}        item        xs={3}        display={{ xs: "none", lg: "block" }}      >        <span>YY</span>      </Box>      <Grid        component={Box}        className={classes.gridItem}        item        xs={3}        display={{ xs: "none", lg: "block" }}      >        <span>ZZ</span>      </Grid>    </Grid>  );}const rootElement = document.getElementById("root");ReactDOM.render(<App />, rootElement);



转载请注明:文章转载自 www.mshxw.com
本文地址:https://www.mshxw.com/it/418065.html
我们一直用心在做
关于我们 文章归档 网站地图 联系我们

版权所有 (c)2021-2022 MSHXW.COM

ICP备案号:晋ICP备2021003244-6号