browser / google chrome / antd-mobile: 1.0.3
code:
<InputItem
{...getFieldProps('phone',
{
initialValue: item.consigneePhone,
rules: [
{required: true, message: '请输入手机号码'},
],
})}
error={!!getFieldError('phone')}
onErrorClick={() => {
Toast.fail(getFieldError('phone'), 1);
}}
type="phone"
placeholder="请输入手机号码">
手机号码
</InputItem>
疑问:
设置 value = '18612341234'
后, 无法进行输入操作
-
设置 defaultValue = '18612341234'
无效, 并且提示警告
`Warning: InputItem contains an input of type tel with both value and defaultValue props. Input elements must be either controlled or uncontrolled (specify either the value prop, or the defaultValue prop, but not both). Decide between using a controlled or uncontrolled input element and remove one of these props. More info: https://fb.me/react-controlled-components`
通过getFieldProps 设置initialValue , value正常, 但是格式需要手动处理
期望结果
设置 value 正常, 可以进行编辑. 并且有格式, eg. 186 1234 1234
与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…