Skip to content

Warning about the Input component #5503

@wvq

Description

@wvq

const inputProps = {
...otherProps,
...attrs,
autocomplete: autocomplete.value,
onChange: handleChange,
onInput: handleChange,
onFocus,
onBlur,
onKeydown: handleKeyDown,
class: classNames(
getInputClassName(prefixCls.value, bordered, size.value, disabled, direction.value),
{
[attrs.class as string]: attrs.class && !addonBefore && !addonAfter,
},
),
ref: inputRef,
key: 'ant-input',
size: htmlSize,
id: otherProps.id ?? formItemContext.id.value,
};
if (valueModifiers.lazy) {
delete inputProps.onInput;
}
if (!inputProps.autofocus) {
delete inputProps.autofocus;
}
const inputNode = <input {...inputProps} />;
return withDirectives(inputNode as VNode, [[antInputDirective]]);

inputProps.size 如果为0或者undefined等任意 false 值, 传递给 <input {...inputProps} />
会报一个warning

[Vue warn]: Failed setting prop "size" on : value 0 is invalid. DOMException: Failed to set the 'size' property on 'HTMLInputElement': The value provided is 0, which is an invalid size.

建议处理一下,开发起来控制台一大堆 warning, 影响很大。

Metadata

Metadata

Assignees

No one assigned

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions