Материальный интерфейс Flexbox - PullRequest
0 голосов
/ 02 мая 2019

У меня есть проблема, когда по какой-то причине максимальная ширина элемента сетки установлена ​​на 16%, но я не уверен, почему.Это приложение реагирует с использованием интерфейса sass, jss и материала.Он также прекрасно работает локально, но проблема проявляется, когда я собираю приложение и запускаю его в производство (что делает его действительно «забавным» для отладки. Я не совсем уверен, что вызывает это.

import React from "react";

// @material-ui/core components
import withStyles from "@material-ui/core/styles/withStyles";
import Grid from "@material-ui/core/Grid";

const style = {
  grid: {
    margin: "0 -15px",
    width: "calc(100% + 30px)"
    // '&:before,&:after':{
    //   display: 'table',
    //   content: '" "',
    // },
    // '&:after':{
    //   clear: 'both',
    // }
  }
};

function GridContainer({ ...props }) {
  console.log('GridContainer', props)
  const { classes, children, className, ...rest } = props;

  let formattedClassName = className ? className : ''

  return (
    <Grid container {...rest} className={classes.grid + " " + formattedClassName + " " + 'classes-grid'}>
      {children}
    </Grid>
  );
}

export default withStyles(style)(GridContainer);

css in production app

У меня нет минимальной ширины: 600 в любом месте приложения, поэтому я не уверен, откуда это.

Кто-нибудь имеет представление о проблеме или даже хороший способ отладки этого? (Я занимался этим часами)

добавление index.html

<!DOCTYPE html>
<html lang="en">
  <head>
    <meta charset="utf-8">
    <meta name="viewport" content="width=device-width, initial-scale=1, shrink-to-fit=no">
    <meta name="theme-color" content="#000000">
    <!--
      manifest.json provides metadata used when your web app is added to the
      homescreen on Android. See https://developers.google.com/web/fundamentals/engage-and-retain/web-app-manifest/
    -->
    <link rel="manifest" href="%PUBLIC_URL%/manifest.json">
    <link rel="shortcut icon" href="%PUBLIC_URL%/favicon.ico">
    <link rel="apple-touch-icon" sizes="76x76" href="%PUBLIC_URL%/apple-icon.png">
    <link rel="stylesheet" href="//cdn.jsdelivr.net/chartist.js/latest/chartist.min.css">
    <script src="//cdn.jsdelivr.net/chartist.js/latest/chartist.min.js"></script>
    <!--
      Notice the use of %PUBLIC_URL% in the tags above.
      It will be replaced with the URL of the `public` folder during the build.
      Only files inside the `public` folder can be referenced from the HTML.

      Unlike "/favicon.ico" or "favicon.ico", "%PUBLIC_URL%/favicon.ico" will
      work correctly both with client-side routing and a non-root public URL.
      Learn how to configure a non-root public URL by running `npm run build`.
    -->
    <title>Manager</title>
  </head>
  <body>
    <noscript>
      You need to enable JavaScript to run this app.
    </noscript>
    <div id="root"></div>
    <!--
      This HTML file is a template.
      If you open it directly in the browser, you will see an empty page.

      You can add webfonts, meta tags, or analytics to this file.
      The build step will place the bundled scripts into the <body> tag.

      To begin the development, run `npm start` or `yarn start`.
      To create a production bundle, use `npm run build` or `yarn build`.
    -->
  </body>
</html>

1 Ответ

0 голосов
/ 02 мая 2019

Я столкнулся с подобной проблемой, когда пытался создать производственную сборку моего приложения, которое использует material-ui.Мне удается решить, добавив JSS-провайдер , как это, посмотрите, работает ли он:

import JssProvider from "react-jss/lib/JssProvider";

class App extends Component {
  render() {
    <JssProvider>
      *the rest of your material-ui components*
    </JssProvider>
  }
}
Добро пожаловать на сайт PullRequest, где вы можете задавать вопросы и получать ответы от других членов сообщества.
...