前言
? ? 我是歌謠 我有個兄弟 巔峰的時候排名c站總榜19 叫前端小歌謠 曾經(jīng)我花了三年的時間創(chuàng)作了他 現(xiàn)在我要用五年的時間超越他 今天又是接近兄弟的一天人生難免坎坷 大不了從頭再來 歌謠的意志是永恒的 放棄很容易 但是堅持一定很酷
導(dǎo)語
? ? 今天在找到我 這邊我們有一個bug需要處理一下 就是輸入框里面不可以輸入數(shù)字 只能輸入文字
? ? <Form.Item label={item.label || ''} {...formItemLayout}>
? ? ? ? ? ? ? ? ? ? {getFieldDecorator(`${item.paramsName}`, {
? ? ? ? ? ? ? ? ? ? ? getValueFromEvent: (event) => {
? ? ? ? ? ? ? ? ? ? ? ? if (item.inputType === 'number' || item.inputType !==
? ? undefined) {
? ? ? ? ? ? ? ? ? ? ? ? ? return event.target.value.replace(/\D/g, '');
? ? ? ? ? ? ? ? ? ? ? ? } else {
? ? ? ? ? ? ? ? ? ? ? ? ? return event.target.value;
? ? ? ? ? ? ? ? ? ? ? ? }
? ? ? ? ? ? ? ? ? ? ? },
? ? ? ? ? ? ? ? ? ? })(<Input placeholder="請輸入" {...item.otherProps} />)}
? ? ? ? ? ? ? ? ? </Form.Item>
運行結(jié)果
? ? 如上限制代碼 則控制成功
后續(xù)
? ? 直接父子傳值給了一個otherProps的屬性
? ? {
? ? ? ? ? ? ? type: 'input',
? ? ? ? ? ? ? label: '客戶ID',
? ? ? ? ? ? ? paramsName: 'customerId',
? ? ? ? ? ? ? otherProps: { type: 'number' },
? ? ? ? ? ? },
? ? 問題解決
————————————————
版權(quán)聲明:本文為CSDN博主「前端大歌謠」的原創(chuàng)文章,遵循CC 4.0 BY-SA版權(quán)協(xié)議,轉(zhuǎn)載請附上原文出處鏈接及本聲明。
原文鏈接:https://blog.csdn.net/geyaoisnice/article/details/121969802