Browse Source

fix: input-password input-search no work

pull/1311/head
wangxueliang 5 years ago
parent
commit
536887a7a7
  1. 2
      components/input/Input.jsx
  2. 29
      components/input/Password.jsx
  3. 1
      components/input/Search.jsx

2
components/input/Input.jsx

@ -5,9 +5,7 @@ import inputProps from './inputProps';
import { hasProp, getComponentFromProp } from '../_util/props-util';
import { isIE, isIE9 } from '../_util/env';
import { ConfigConsumerProps } from '../config-provider';
import Password from './Password';
import Icon from '../icon';
import warning from '../_util/warning';
function noop() {}

29
components/input/Password.js → components/input/Password.jsx

@ -1,4 +1,5 @@
import classNames from 'classnames';
import { getComponentFromProp, getOptionProps } from '../_util/props-util';
import Input from './Input';
import Icon from '../icon';
import inputProps from './inputProps';
@ -57,19 +58,33 @@ export default {
},
},
render() {
const { prefixCls, inputPrefixCls, size, suffix, visibilityToggle, ...restProps } = this.$props;
const { prefixCls, inputPrefixCls, size, suffix, visibilityToggle, ...restProps } = getOptionProps(this);
const suffixIcon = visibilityToggle && this.getIcon();
const inputClassName = classNames(prefixCls, {
[`${prefixCls}-${size}`]: !!size,
});
const inputProps = {
props: {
...restProps,
prefixCls: inputPrefixCls,
size,
suffix: suffixIcon,
prefix: getComponentFromProp(this, 'prefix'),
addonAfter: getComponentFromProp(this, 'addonAfter'),
addonBefore: getComponentFromProp(this, 'addonBefore'),
},
attrs: {
...this.$attrs,
type: this.visible ? 'text' : 'password',
},
class: inputClassName,
on: {
...this.$listeners,
},
};
return (
<Input
{...restProps}
type={this.visible ? 'text' : 'password'}
size={size}
class={inputClassName}
prefixCls={inputPrefixCls}
suffix={suffixIcon}
{...inputProps}
/>
);
},

1
components/input/Search.jsx

@ -127,6 +127,7 @@ export default {
prefixCls: inputPrefixCls,
size,
suffix: this.renderSuffix(prefixCls),
prefix: getComponentFromProp(this, 'prefix'),
addonAfter: this.renderAddonAfter(prefixCls),
addonBefore,
},

Loading…
Cancel
Save