【发布时间】:2020-07-14 22:10:45
【问题描述】:
我无法弄清楚如何呈现轮廓输入类型(与文本掩码一起使用时的标准 Material-UI 输入样式之一)。
我从这里复制了代码示例:https://material-ui.com/components/text-fields/ 但它只提供了常规(下划线)输入的示例,但没有提供概述。
这是我正在尝试做的,但它不起作用:
const ExpirationMask = props => {
const { inputRef, ...other } = props
return <MaskedInput
{...other}
ref={ref => {inputRef(ref ? ref.inputElement : null)}}
mask={[/\d/, /\d/,'/' ,/\d/, /\d/]}
placeholderChar={'\u2000'}
/>
}
<FormControl
variant='outlined' //this doesnt work
fullWidth
>
<InputLabel>Expiration</InputLabel>
<Input
value={ccExpiration}
onChange={(e, v) => setCCExpiration(e.target.value)}
placeholder='MM/YY'
variant='outlined' //this doesnt work either
inputComponent={ExpirationMask}
/>
</FormControl>
【问题讨论】:
-
AFAIK 变体是
组件的属性,您将其用于输入。输入没有变体属性。
标签: reactjs material-ui