reactjs - reactjss上的多种样式扩展不起作用
问题描述
我正在使用数组在 react-jss 上进行多个扩展,但它不起作用。
const styles = (theme) => ({
flexDisplay: {
display: 'flex',
'align-items': 'center'
},
headerBackground: {
'background-color': defaultTheme.headerBackground
},
headerRowCell:{
extend: ['headerBackground','flexDisplay'],
'padding': '0.5em 0.5em',
'color': theme.secondaryTextColor || defaultTheme.secondaryTextColor,
'text-transform': 'uppercase',
height: '48px',
}
});
这是错误。
解决方案
为了解决这个问题,我们需要创建扩展对象并将对象传递给数组所需的样式对象
const flexDisplay = {
display: 'flex',
'align-items': 'center'
};
const headerBackground = {
'background-color': defaultTheme.headerBackground
};
const styles = (theme) => ({
headerRowCell:{
extend: [headerBackground, flexDisplay],
'padding': '0.5em 0.5em',
'color': theme.secondaryTextColor || defaultTheme.secondaryTextColor,
'text-transform': 'uppercase',
height: '48px',
}
});
推荐阅读
- azure - 无法将 Spring-boot 应用部署到 Azure 应用服务
- matplotlib - 如何为单图 matplotlib 生成多个图例
- html - 使用 Flexbox 悬停时隐藏图像并显示文本区域
- python - 如何组合两个 numpy 数组,以便为第一个数组的每一行附加第二个数组的所有行?
- sql - 如何在 SQLite 中重用递归 WITH 子句?
- machine-learning - 尝试列出所有图像以进行预处理但出现错误
- sql - Microsoft SQL Server 中是否存在类似 PLV8 的内容?
- c++ - GLEW 错误 (1):缺少 GL 版本 (GLFW)
- java - 如何从 Firebase 数据库 Android 获取嵌套推送键
- batch-file - 当另一个程序关闭 .Bat 文件时关闭程序