我閱讀了如何將 1 個道具傳遞到makeStyle()此處,并提出了以下方法,用于傳遞2 個道具的任務。但錯誤讀取cannot find name 'props'。任何幫助將非常感激!
const Foo = ({ bar, color, backgroundColor }) => {
const classes = useStyles({color, backgroundColor});
...
};
type Props = {
color: string
backgroundColor: string
}
const useStyles = makeStyles<Theme, Props>((theme: Theme) =>
createStyles({
...BaseTheme(theme),
main: {
color: `${props.color}`,
backgroundColor: `${props.backgroundColor}`,
},
}),
);
uj5u.com熱心網友回復:
我認為它應該是一個props作為main屬性引數的函式。
type Props = {
color: string
backgroundColor: string
}
const useStyles = makeStyles<Theme, Props>((theme: Theme) =>
createStyles({
...BaseTheme(theme),
main: (props: Props) => ({
color: `${props.color}`,
backgroundColor: `${props.backgroundColor}`,
}),
}),
);
轉載請註明出處,本文鏈接:https://www.uj5u.com/net/508374.html
上一篇:輸入'可觀察的<true|undefined>'不能分配給angularauthguard實作上的型別'Observable<boolean>
