[英]How to mask a Material-ui FilledInput
I'm trying to mask a FilledInput
Material-ui component to display as currency using this package: https://www.npmjs.com/package/react-currency-format我正在尝试使用此包屏蔽FilledInput
Material-ui 组件以显示为货币: https : FilledInput
I tried many different approaches, but none works right.我尝试了许多不同的方法,但没有一个是正确的。 I created a codesandbox with the problem: https://codesandbox.io/s/fancy-silence-vjkxq我创建了一个带有问题的代码沙盒: https ://codesandbox.io/s/fancy-silence-vjkxq
Right now I'm implementing this way:现在我正在以这种方式实施:
function Amount({ handleChange, values, t }) {
return (
<FormControl fullWidth variant="filled">
<InputLabel htmlFor="amount">{t("Send")}</InputLabel>
<FilledInput
name="amount"
onChange={handleChange}
value={values.amount}
startAdornment={
<InputAdornment position="start">€</InputAdornment>
}
/>
</FormControl>
);
}
export default function ExchangeRateProvider() {
return (
<CurrencyFormat
customInput={Amount}
handleChange={handleAmount}
t={t}
value={values.amount}
thousandSeparator={true}
/>
)
}
The code works fine, it updates the numbers and the material-ui
component is applied, however the mask doesn't work.代码工作正常,它更新了数字并应用了material-ui
组件,但是遮罩不起作用。
Thanks in advance提前致谢
Something like this?像这样的东西?
function App() {
const [value, setValue] = useState("0");
const handleChange = event => {
const { value } = event.target;
setValue(value);
};
return (
<div className="App">
<CurrencyFormat
value={value}
onChange={handleChange}
displayType={"input"}
customInput={FilledInput}
thousandSeparator={true}
startAdornment={<InputAdornment position="start">€</InputAdornment>}
/>
</div>
);
}
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.