fix: input-password input-search no work

pull/1311/head
wangxueliang 5 years ago
parent 5178480d13
commit 536887a7a7

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

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

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

Loading…
Cancel
Save