本文介绍了为什么Material-UI无法识别theme.spacing功能?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我正在尝试在React应用程序中使用Material-UI的 theme.spacing 功能,但无法识别 spacing 功能.

I am trying to use Material-UI's theme.spacing function in a React application but the spacing function is not recognized.

Javascript错误消息是: TypeError:theme.spacing不是函数

The Javascript error message is: TypeError: theme.spacing is not a function

我不确定这是错误还是安装的框架版本有问题.

I am unsure if this is a bug or I have something wrong with the frameworks versions being installed.

  • Here's the Github issue raised to address this problem.
  • Here's the repo with the offending code. The error is caught in the src\pages\index.js file, line 16:paddingTop: theme.spacing(20)
  • Here's the sandboxed repo running where you can actually see the error message.

根据 package-lock.json 文件,这些是正在安装的框架版本:

These are the frameworks versions being installed, according to the package-lock.json file:

  • 材料界面:v3.9.2
  • 反应:v16.8.1
  • Chrome浏览器:v72.0.3626.96
  • TypeScript:无
  • create-react-app:v3.2.2

推荐答案

好吧,事实证明这毕竟是一个错误,由请求#14099 .

Well, it turns out this is a bug after all, caused by request #14099.

现在正在解决问题,所以我要解决这个问题.

A fix is on the way now, so I am closing this question.

这篇关于为什么Material-UI无法识别theme.spacing功能?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!

08-18 11:15