使用 Material-UI 创建颜色主题时,我将对比文本设置为白色 (#fff)。它适用于具有主要颜色的按钮,但不适用于次要颜色。
按此处所述尝试覆盖:材料 UI:无法更改主题中的按钮文本颜色。如果覆盖可以解决它,那么我需要帮助编写一个。
const colortheme = createMuiTheme({
palette: {
primary: { main: '#e91e63' },
secondary: { main: '#03a9f4' },
contrastText: '#fff',
}
});
Run Code Online (Sandbox Code Playgroud)
期望两个按钮都有白色文本。取而代之的是一键黑色:
编辑:我创建了主题并在父级上呈现 Material UI 的 SimpleModal 组件,将主题道具传递给子级。该按钮呈现在孩子身上。
家长:
const blues = createMuiTheme({
palette: {
primary: { main: '#00e5ff' },
secondary: { main: '#2979ff' },
contrastText: '#fff'
}
})
<SimpleModal label="content" theme={blues} color="primary" document="content" />
Run Code Online (Sandbox Code Playgroud)
孩子:
<div>
<MuiThemeProvider theme={this.props.theme}>
<Button className={classes.margin} variant="contained" color={this.props.color} onClick={this.handleOpen}>{this.props.label}</Button>
</MuiThemeProvider>
<Modal open={this.state.open} onClose={this.handleClose}>
<div style={getModalStyle()} className={classes.paper}>
<Typography variant="h6" …Run Code Online (Sandbox Code Playgroud) 我正在学习正则表达式.如果我想在字符串中找到所有5个字母的单词,我可以使用:
import re
text = 'The quick brown fox jumps over the lazy dog.'
print(re.findall(r"\b[a-zA-z]{5}\b", text))
Run Code Online (Sandbox Code Playgroud)
但是我想写一个简单的函数,其参数包括字符串和找到的单词的长度.我试过这个:
import re
def findwords(text, n):
return re.findall(r"\b[a-zA-z]{n}\b", text)
print(findwords('The quick brown fox jumps over the lazy dog.', 5))
Run Code Online (Sandbox Code Playgroud)
但是这会返回一个空列表.这n是不被承认的.
如何用重复次数(或者在这种情况下,单词的长度)指定一个参数?