这是Error中显示的样式:
第一个
这就是准则
import React from 'react'
import { Button } from '@mui/material'
type Props = {
title: string
type?: string
style?: React.CSSProperties
onClick?: (args: any) => void;
isActive?: boolean
}
const ButtonComponent = (props: Props) => {
const styleButton = (type: string, isActive: boolean) => {
if (type === 'tabButton')
return {
width: '200px',
height: '40px',
padding: '10px 20px',
borderRadius: '20px',
fontSize: '16px',
fontFamily: 'Open Sans',
fontWeight: isActive? '700':'400',
color: isActive? '#FFFFFF': '#161F29',
background: isActive?'#161F29':'rgba(255, 255, 255, 0.5)',
border: '1px solid rgba(22, 31, 41, 0.5)',
textTransform: 'capitalize'
}
return (
<div>
<Button
style = {styleButton(props.type || '', props.isActive || false)}
onClick= {props.onClick
}
>
{props.title}
</Button>
</div>
)
}
export default ButtonComponent;
ButtonComponent.defaultProps = {
title: "",
type: "",
style: {},
onClick: () => null,
isActive: false
}
2条答案
按热度按时间2guxujil1#
请定义React样式按钮的返回类型。CSS属性
lrpiutwd2#
在这里,
textTransform
应该是texttransform
,而在styleButton
的末尾缺少了}
。styleButton
的正确代码应该如下所示: