问题描述
我正在尝试在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.
- 在这里提出了 Github问题. li>
- 这是回购,其中包含有问题的代码.错误被捕获在 src \ pages \ index.js 文件,第16行:
paddingTop:theme.spacing(20)
- 在这里沙盒存储库运行,您可以在其中实际看到错误消息.
- 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功能?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!