javascript - 使用 Material UI 中的 theme.breakpoints.down('') 时出错
问题描述
我是初学者,我在前端使用材料 UI,我试图根据材料 UI 中的文档使用 theme.breakpoints.down 使我的应用程序响应,但它返回错误:
这就是我的代码:
const useStyle = makeStyles({
root : {
height:"100vh",
display:"flex",
justifyContent:"space-evenly",
alignItems:"center",
[theme.breakpoints.down('sm')]:{
flexDirection:"column"
}
}
})
我想了解发生了什么,如果可能的话,可以做些什么来解决它。谢谢你。
解决方案
makeStyles 是一个函数并返回钩子,因此您可以将“主题”作为参数传递
所以应该是这样的:
const useStyle = makeStyles((theme)=>({
root : {
height:"100vh",
display:"flex",
justifyContent:"space-evenly",
alignItems:"center",
[theme.breakpoints.down('sm')]:{
flexDirection:"column"
}
}}))
推荐阅读
- r - 如何按两个变量分组并获取计数,以及“传播”第二个变量,所有这些都在 data.table 中
- apache-spark - 从 S3 存储桶读取文件到 PySpark Dataframe Boto3
- class - 未分配给正确变量的属性值
- java - Base64.getDecoder() 使用相同的字符串输入返回不同的答案
- javascript - 为什么快递服务器不提供压缩的 .gz 文件?
- nativescript - Branch.io 与 nativescript 集成?
- ambari - ambari-agent 无法访问 ambari-server
- django - Django:使用列表中的项目而不在视图中执行for循环
- mysql - 如何在我的计数中获得满足语句的值?
- java - 调用 REST 控制器方法返回 404 null