gpt4 book ai didi

javascript - 收到错误 TypeError : color. charAt is not a function in C :/. ..../node_modules/@material-ui/core/styles/colorManipulator.js:148

转载 作者:塔克拉玛干 更新时间:2023-11-02 21:23:32 26 4
gpt4 key购买 nike

这里是错误截图的链接:https://drive.google.com/open?id=1HL-Fy1M4tHp9qMUpt88PzOfI10AHHem- .

这是使用颜色的代码部分。

const theme = createMuiTheme({
palette: {
primary: {
light: '#33c9dc',
main: '#00bcd4',
dark: '#008394',
contrastText: '#fff'
},
secondary: {
light: '#ff6333',
main: '#ff3d00',
dark: '#b22a00',
contrastText: '#fff'
}
},
typography: {
useNextVariants: true
},
form: {
textAlign: "center"
},
image: {
margin: "10px auto 10px auto"
},
pageTitle: {
margin: "10px auto 10px auto"
},
textField: {
margin: "10px auto 10px auto"
},
button: {
marginTop: 20,
position: "relative"
},
customError: {
color: "red",
fontSize: "0.8rem",
marginTop: 5
},
progress: {
position: "absolute"
}
});

我已经尝试将颜色从十六进制值更改为 rgb 值,但没有用。

最佳答案

我对这个问题的解决方案是将所有样式对象放在另一个对象中,而忽略(调色板)对象,并只展开不包含(调色板)的对象

const theme = createMuiTheme({
palette: {
primary: {
light: '#33c9dc',
main: '#00bcd4',
dark: '#008394',
contrastText: '#fff'
},
secondary: {
light: '#ff6333',
main: '#ff3d00',
dark: '#b22a00',
contrastText: '#fff'
}
},

// the object to be spread
spreadThis: {
typography: {
useNextVariants: true
},
form: {
textAlign: "center"
},
image: {
margin: "10px auto 10px auto"
},
pageTitle: {
margin: "10px auto 10px auto"
},
textField: {
margin: "10px auto 10px auto"
},
button: {
marginTop: 20,
position: "relative"
},
customError: {
color: "red",
fontSize: "0.8rem",
marginTop: 5
},
progress: {
position: "absolute"
}
}
});

现在您可以在样式对象中执行此操作

const style = theme => ({
...theme.spreadThis
});

希望这对你也有用!祝你好运

关于javascript - 收到错误 TypeError : color. charAt is not a function in C :/. ..../node_modules/@material-ui/core/styles/colorManipulator.js:148,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/56897838/

26 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com